The first thing to do is to check the Docker logs. First, get the ID for the container by using the “–a” flag to list all containers, including stopped containers as shown:
docker ps –a
Once you have the image ID, view the logs by typing
docker logs <id>
If the answer isn’t immediately obvious, you can connect to the container directly as we discussed earlier in the chapter by overriding the container’s entrypoint in the Docker run command as shown below:
docker run –t -i -p 80:80 --entrypoint=/bin/bash thedanfernandez/
productcatalog
This snippet replaces the “–d” (detached) flag with the “–i” flag to run interactively and overrides the Dockerfile entrypoint to instead start the bash command prompt. Once it runs, you should see a bash command prompt that you can use to further diagnose issues such as:
• ensuring all application dependencies are in the base image.
• ensuring any apps or dependencies (ex: NPM) are installed.
• ensuring any environment variables your app needs are correctly configured.
When you type “exit
” to exit the interactive shell, the container will automatically stop, but you can go back and use the Docker logs command to view all the commands you typed into the bash shell and the corresponding command line output.
3.129.21.47