edit-icon download-icon

Collect standard Docker logs

Last Updated: May 23, 2018

Logtail supports collecting standard Docker logs and uploading these logs together with the container-related metadata information to Log Service.

Configuration process


  1. Deploy the Logtail container.

  2. Configure the Logtail container.

    In the Log Service console, create a machine group with the user-defined identity. Then, no additional Operation & Maintenance (O&M) is needed to expand or contract the container cluster.

  3. Create collection configurations in the console.

    Create collection configurations in the Log Service console. All the collection configurations are for the server side. No local configuration is needed.


Step 1. Deploy the Logtail container

  1. Pull the Logtail image.

    docker pull registry.cn-hangzhou.aliyuncs.com/log-service/logtail

  2. Start the Logtail container.

    Replace the following three parameters in the startup template: ${your_region_name}, ${your_aliyun_user_id}, and ${your_machine_group_user_defined_id}.

    1. docker run -d -v /:/logtail_host:ro -v /var/run/docker.sock:/var/run/docker.sock --env ALIYUN_LOGTAIL_CONFIG=/etc/ilogtail/conf/${your_region_name}/ilogtail_config.json --env ALIYUN_LOGTAIL_USER_ID=${your_aliyun_user_id} --env ALIYUN_LOGTAIL_USER_DEFINED_ID=${your_machine_group_user_defined_id} registry.cn-hangzhou.aliyuncs.com/log-service/logtail
    Parameter Description
    ${your_region_name} The region name. Replace it with the region where your created Log Service project resides. For the region name, see the region name used in Install Logtail.
    Note: We recommend that you copy the region name directly from the list.
    ${your_aliyun_user_id} The user identification. Replace it with the ID of your Alibaba Cloud main account, which is in the string format. For how to check the ID, see 2.1 in User identification settings.
    ${your_machine_group__user_defined_id} The user-defined identity of your cluster machine group. If user-defined identity is not enabled yet, enable userdefined-id by following the corresponding steps in Custom machine groups.


    1. docker run -d -v /:/logtail_host:ro -v /var/run/docker.sock:/var/run/docker.sock --env ALIYUN_LOGTAIL_CONFIG=/etc/ilogtail/conf/cn_hangzhou/ilogtail_config.json --env ALIYUN_LOGTAIL_USER_ID=1654218****** --env ALIYUN_LOGTAIL_USER_DEFINED_ID=log-docker-demo registry.cn-hangzhou.aliyuncs.com/log-service/logtail


You can customize the startup parameter configurations of Logtail containers if the following conditions are met:

  1. You have the following three environment variables when starting the Logtail containers: ALIYUN_LOGTAIL_USER_DEFINED_ID, ALIYUN_LOGTAIL_USER_ID, and ALIYUN_LOGTAIL_CONFIG.

  2. The domain socket of Docker is mounted to /var/run/docker.sock.

  3. If you want to collect logs from other containers or host files, the root directory is mounted to the /logtail_host directory of Logtail containers.

Step 2. Configure machine group

  1. Activate Log Service, and create Project and Logstore. For more information, see Preparation.

  2. Click Create Machine Group on the Machine Groups page in the Log Service console.

  3. Select User-defined Identity from the Machine Group Identification drop-down list. Enter the ALIYUN_LOGTAIL_USER_DEFINED_ID configured in the previous step in the User-defined Identity field.


    Click Confirm to create the machine group. One minute later, click Machine Status at the right of the machine group on the Machine Groups page to view the heartbeat status of the deployed Logtail container. For more information, see View status in Configure machine groups.

Step 3. Create collection configurations

Create Logtail collection configurations in the console as needed. For how to create collection configurations, see:

Other operations

Check the running status of the Logtail container

You can run the docker exec ${logtail_container_id} /etc/init.d/ilogtaild status command to check the running status of Logtail.

Check version number, IP, and startup time of Logtail

You can run the docker exec ${logtail_container_id} cat /usr/local/ilogtail/app_info.json command to check the information related to Logtail.

Check Logtail running logs

Logtail running logs are stored in the /usr/local/ilogtail/ directory. The file name is ilogtail.LOG. The rotation file is compressed and stored as ilogtail.LOG.x.gz.


  1. [root@iZbp17enxc2us3624wexh2Z ilogtail]# docker exec a287de895e40 tail -n 5 /usr/local/ilogtail/ilogtail.LOG
  2. [2018-02-06 08:13:35.721864] [INFO] [8] [build/release64/sls/ilogtail/LogtailPlugin.cpp:104] logtail plugin Resume:start
  3. [2018-02-06 08:13:35.722135] [INFO] [8] [build/release64/sls/ilogtail/LogtailPlugin.cpp:106] logtail plugin Resume:success
  4. [2018-02-06 08:13:35.722149] [INFO] [8] [build/release64/sls/ilogtail/EventDispatcher.cpp:369] start add existed check point events, size:0
  5. [2018-02-06 08:13:35.722155] [INFO] [8] [build/release64/sls/ilogtail/EventDispatcher.cpp:511] add existed check point events, size:0 cache size:0 event size:0 success count:0
  6. [2018-02-06 08:13:39.725417] [INFO] [8] [build/release64/sls/ilogtail/ConfigManager.cpp:3776] check container path update flag:0 size:1

Restart Logtail

See the following example to restart Logtail:

  1. [root@iZbp17enxc2us3624wexh2Z ilogtail]# docker exec a287de895e40 /etc/init.d/ilogtaild stop
  2. kill process Name: ilogtail pid: 7
  3. kill process Name: ilogtail pid: 8
  4. stop success
  5. [root@iZbp17enxc2us3624wexh2Z ilogtail]# docker exec a287de895e40 /etc/init.d/ilogtaild start
  6. ilogtail is running
Thank you! We've received your feedback.