Diagnosing a Running Container

To do the same kind of diagnostics on a running container, you can either:

attach to the container using the docker attach command.

use the docker exec command to execute commands in the container and return the result to the command prompt using docker exec <container-id> command.

For example, you can call the exec command on the elasticsearch container using the first four characters of the container id, “bbd8,” to view the contents of a file using the Linux cat command.

docker exec bbd8 cat docker-entrypoint.sh

This will execute the command in the container and return the output, in this case the contents of the docker-entrypoint.sh file as shown in Figure 4.9.

FIGURE 4.9: ...

Get Microservices with Docker on Microsoft Azure™ (includes Content Update Program) now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.