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.

Image

FIGURE 4.9: Using Docker Exec to see the contents of a file in a running container

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.97.187