DEV Community

Le Vuong
Le Vuong

Posted on

1 1 1

Simple steps to debug docker build

Below are steps to debug docker build. In this example, docker is a python app, but the same logic apply to other languages and frameworks.

  1. In the Dockerfile, comment the lines that cause the build to fail and all other lines below that; Then add below line to the end of the Dockerfile.

CMD ["bash"]

  1. Build again (this time it should success) and start the container.
    docker run <image name>

  2. Connect to the container: docker exec -it <container> bash

  3. Run the steps that cause the build error (in Dockerfile).
    Eg. pip install -s requirements.txt

  4. Investigate and try to fix the failed commands.

  5. Continue with next other commands in the Dockerfile until everything is ok.

  6. When finished, uncomment the commented lines in Dockerfile in step 1.

  7. Try and build Dockerfile again.

References:

  • How to build docker
  • How to dockerize an app

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay