Docker on Amazon Web Services
上QQ阅读APP看书,第一时间看更新

Inspecting the ECS agent

As shown previously, the ECS agent runs as a Docker container, and we can use the docker container inspect command to gather some insight about how this container works. In the previous example, we reference the name of the ECS agent container, and then use a Go template expression along with the --format flag to filter the command output, displaying the various bind mounts or volume mappings from the ECS agent container to the ECS container instance host.

In many of the command examples, I am piping output to the jq utility, which is a useful utility used for parsing JSON output at the command line. jq is not included by default in the Amazon Linux AMI, so you will need to install jq by running the sudo yum install jq command.
> docker container inspect ecs-agent --format '{{json .HostConfig.Binds}}' | jq
[
"/var/run:/var/run",
"/var/log/ecs:/log",
"/var/lib/ecs/data:/data",
"/etc/ecs:/etc/ecs",
"/var/cache/ecs:/var/cache/ecs",
"/cgroup:/sys/fs/cgroup",
"/proc:/host/proc:ro",
"/var/lib/ecs/dhclient:/var/lib/dhclient",
"/lib64:/lib64:ro",
"/sbin:/sbin:ro"
]
Running the docker container inspect co mmand

Notice that the /var/run folder is mapped from the host to the agent, which provides access to the Docker Engine socket located at /var/run/docker.sock, allowing the ECS agent to manage the Docker Engine. You can also see that ECS agent logs will be written to /var/log/ecs on the Docker Engine host file system.