Log Service allows you to collect logs from containers. You can specify the containers
by label or environment variable. Labels are retrieved by running the docker inspect
command and environment variables are specified in the startup configuration of each
container.
Obtain container labels
- Log on to the host where the container whose labels you want to obtain resides, for
example, an Elastic Compute Service (ECS) instance.
- Run the following command to obtain the ID of the container.
The
orders variable in the command is the name of a container group. Replace the value of the
variable with an actual name.
docker ps | grep orders
2ba4ebdaf503 in the response indicates the ID of the container.

- Run the following command to obtain the labels of the container.
The
2ba4ebdaf503 variable in the command is the ID of a container. Replace the value of the variable
with an actual ID.
docker inspect 2ba4ebdaf503
The Labels field in the response indicates the container labels.

Obtain environment variables
- Log on to the host where the container whose labels you want to obtain resides, for
example, an Elastic Compute Service (ECS) instance.
- Run the following command to obtain the ID of the container.
The
orders variable in the command is the name of a container group. Replace the value of the
variable with an actual name.
docker ps | grep orders
2ba4ebdaf503 in the response indicates the ID of the container.

- Run the following command to obtain the environment variables of the container.
The
2ba4ebdaf503 variable in the command is the ID of a container. Replace the value of the variable
with an actual ID.
docker exec 2ba4ebdaf503 env
