Low Orbit Flux Logo 2 F

Docker How To Debug

There are serveral different ways in which you can debug a Docker container.

The first thing you want to do is make sure that a container is up and running. You also want to make sure that it isn’t repeatedly restarting so pay attention to the start time.



docker ps -a 

The next thing that you are going to want to do is check the logs. Specify the container with the following command:



docker logs pedantic_merkle

Tail the logs as they are written:



docker logs -f 

Remember to grep for whatever you are looking for:



docker logs pedantic_merkle | grep -i error

You can launch a shell on a container. This will allow you to run whatever commands you need to test and examine the system.



docker exec -it inspiring_dhawan bash

You can also run any other command you might like insead of launching bash. Just make sure that the tool is installed on the system.

Alternatively, you could attach to a container ( I perfer just launching bash with exec ).



docker attach inspiring_cray

To detach, press these keys, in order:



[ctrl] - p
[ctrl] - q 

You can inspect a containers state and settings with this.



docker inspect inspiring_cray

You can use top to view proceses in a container like this:



docker top ubuntu

You can override the entry point like this:



docker run -d -p 80:80 --entrypoint /bin/sh /mysw/alternate-app

You can pass extra parameters. Everything after the iamge name will be passed as parameters to the to the container.



docker run -d -p 80:8000 myapp 0.0.0.0:8000

You can pause and unpause a container like this:



docker pause ubuntu
docker unpause ubuntu

You could also look into the image layers like this:



docker history myapp