9  Troubleshooting Tips

This chapter will demonstrate how to: Recognize common Docker issues and error messages and their likely causes Develop strategies for addressing these errors

9.0.1 Tips for troubleshooting

First remind yourself of the lessons we discussed in the activities in Chapter 3:

Recall, because containers are isolated from  your computer. If you are missing files, you can re-run the container but add a volume. If you are missing software you can edit your dockerfile and re-build.

Then ask yourself the following questions:

  • Is there a file that I’m assuming the image/container has that it does not?
  • Is there a software package I’m assuming the image/container has that it does not?
  • Is there a typo?
  • Am I missing a dependency? Make sure the dependency’s RUN steps come before the software package that needs it.
  • Did the base image I’m pulling from change or a file I’m COPYing change? Do I need to use –no-cache to force a rebuild of everything so the changes are seen?

Now you have the basics of using containers but this is really just the beginning! As you continue to work with containers you will encounter errors and need to troubleshoot. This table has a quick rundown on some of the most common errors:

The table shows three columns: Error message or problem, Most likely cause, Recommended Strategies. If you have the problem: Cannot connect to the Docker daemon … Is the docker daemon running? The most likely cause is: The Docker application is not running! Recommended Strategies for this is to. Turn on Docker!If you have the problem: Docker build FAILS The most likely cause is: Probably one of the installation commands isn’t working. Recommended Strategies for this is to: Look for other people’s Dockerfiles with installation steps for the software you are trying to install, Use Google/StackOverflow of course. If you have the problem: Image not found The most likely cause is: The image you are referencing in a Dockerfile either doesn’t exist or you don’t have access to it. Recommended Strategies for this is to: Double check your spelling in the FROM bit Docker pull! If you have the problem: Out of memory (OOM) or “Killed” The most likely cause is: Docker doesn’t have enough memory to run what it needs to! Recommended Strategies for this is to: Try deleting images and containers to free up memory. Go to Settings > Resources to check how much Docker has been allocated

9.1 Activity Instructions

9.1.1 Docker

There are three Dockerfiles in the activity-files folder. Each has something slightly wrong with it.

Use the following docker build commands and work to pinpoint the error and fix it using the tips we discussed in this chapter.

9.1.1.1 Bad Dockerfile 1:

docker build -f Bad_Dockerfile_1 .

9.1.1.2 Bad Dockerfile 2:

docker build -f Bad_Dockerfile_2 .

9.1.1.3 Bad Dockerfile 3:

docker build -f Bad_Dockerfile_3 .

9.1.2 Podman

There are three Dockerfiles in the activity-files folder. Each has something slightly wrong with it.

Use the following podman build commands and work to pinpoint the error and fix it using the tips we discussed in this chapter.

9.1.2.1 Bad Dockerfile 1:

podman build -f Bad_Dockerfile_1 .

9.1.2.2 Bad Dockerfile 2:

podman build -f Bad_Dockerfile_2 .

9.1.2.3 Bad Dockerfile 3:

podman build -f Bad_Dockerfile_3 .

9.2 SPOILERS: Hints for each of the dockerfiles

Bad_Dockerfile_1 hint Carefully look at the name of base image that is being pulled from.
Bad_Dockerfile_2 hint Are the commands that are referenced installed on the base image?
Bad_Dockerfile_3 hint Is the file that is being copied over with COPY specified correctly?