Dockerfile debugging
Today I was working with Dockerfile which would download a package from internet , unzip it and then install it as component.
Learnings during the process:
1. Every command in Dockerfile is executed in a different intermediate container which serves as base of the next command.
2. This helped to debug the application. I was getting issues where it could download the file but would not unzip saying it is not in gzip format. Running curl command on local, I was getting right tar file and was able to decomress as well. So what was wrong.
To figure it out I wanted to debug the command in docker file, so figured following command to debug the image at different stages:
docker run --rm -it <instance id of last container in docker run> sh
This will launch the last container with the command executed that was successful and then I could see the output of the command and run remaining commands on the same image to fix my Dockerfile.
(It was a proxy issue offcourse :) )
Learnings during the process:
1. Every command in Dockerfile is executed in a different intermediate container which serves as base of the next command.
2. This helped to debug the application. I was getting issues where it could download the file but would not unzip saying it is not in gzip format. Running curl command on local, I was getting right tar file and was able to decomress as well. So what was wrong.
To figure it out I wanted to debug the command in docker file, so figured following command to debug the image at different stages:
docker run --rm -it <instance id of last container in docker run> sh
This will launch the last container with the command executed that was successful and then I could see the output of the command and run remaining commands on the same image to fix my Dockerfile.
(It was a proxy issue offcourse :) )
Comments
Post a Comment