joe, Yesterday, I wrote about how I moved a mastodon bot from Pipedream to a docker container. Docker is an efficient way of running isolated little scripts like that. Today, I wanted to review some basic debugging techniques to ensure your script runs as expected.
What docker images exist on the system?
When we looked at how to dockerize a node app, I said that you create a docker image and then run it as a container. So, how do you list the docker images on a system? You run
docker images
.What docker containers exist on the system?
If you run
docker ps
, you can get what containers are running, and if you rundocker ps -a
, it will include containers that aren’t running.How do you access a container’s shell?
Like a VM or a system running on bare metal, you can get a shell inside of the docker container. The first step is knowing the container ID for the container you want a shell for. If you look at the output from the
docker ps
command, you can find it.At this point, you run
docker exec -it [container id] /bin/sh
to get a shell inside the container.Once you know that the image is there, know if it is running or not, and have a shell inside the container, you should be able to find what is wrong with your container.
Have a questions, comment, etc? Feel free to drop a comment, below.