I am building a multi-step image from a Dockerfile, but one step currently fails. What I would like to do is to run the last successful step in interactive and debug it.
Unfortunately Docker removes the intermediate container:
Removing intermediate container dac6772bcf71
---> aa6de00f27db
So I cannot do:
docker run -it dac6772bcf71 /bin/bash
I have found the --force-rm option but not the keep-intermediate one.
How is it possible to tell Docker to keep intermediate containers?
Concrete example
IRL, I have this:
Removing intermediate container dac6772bcf71
---> aa6de00f27db
Step 9/9 : RUN pip install git+https://github.com/heig-vd-tin/sphinx-heigvd-theme.git
---> Running in a4745435a814
Collecting git+https://github.com/heig-vd-tin/sphinx-heigvd-theme.git
Cloning https://github.com/heig-vd-tin/sphinx-heigvd-theme.git to /tmp/pip-req-build-AKf_Kz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-AKf_Kz/setup.py", line 2, in <module>
import sphinx_heigvd_theme
File "sphinx_heigvd_theme/__init__.py", line 141
toc_href = f'{relative_uri(baseuri, toc_uri)}#{anchor_id}'
So it seems my Python is < 3.6, but I want to check that. One possibility would be to do:
docker run dac6772bcf71 python --version
But I cannot, because the parent container was automatically destroyed.
You don't need to build the entire Dockerfile, you can stop at a certain stage in your build. Just build with a command like this:
docker build --target builder -t alexellis2/href-counter:latest .
Example taken from the official docs, you can read more here: https://docs.docker.com/develop/develop-images/multistage-build/ under "Stop at specific build stage".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With