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.
- 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"]
Build again (this time it should success) and start the container.
docker run <image name>
Connect to the container:
docker exec -it <container> bash
Run the steps that cause the build error (in Dockerfile).
Eg.pip install -s requirements.txt
Investigate and try to fix the failed commands.
Continue with next other commands in the Dockerfile until everything is ok.
When finished, uncomment the commented lines in Dockerfile in step 1.
Try and build Dockerfile again.
References:
- How to build docker
- How to dockerize an app
Top comments (0)