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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay