debugging - How can I inspect the file system of a failed `docker build`? - Stack Overflow
Everytime docker successfully executes a RUN
command from a Dockerfile, a new layer in the image filesystem is committed. Conveniently you can use those layers ids as images to start a new container.
Take the following Dockerfile:
FROM base RUN echo 'foo' > /tmp/foo.txt RUN echo 'bar' >> /tmp/foo.txt
and build it:
$ docker build --force-rm -t so-26220957 . Sending build context to Docker daemon 3.584 kB Sending build context to Docker daemon Step 0 : FROM base ---> b750fe79269d Step 1 : RUN echo 'foo' > /tmp/foo.txt ---> Running in d37d756f6e55 ---> de1d48805de2 Removing intermediate container d37d756f6e55 Step 2 : RUN echo 'bar' >> /tmp/foo.txt ---> Running in a180fdacd268 ---> 40fd00ee38e1 Removing intermediate container a180fdacd268 Successfully built 40fd00ee38e1
You can now start a new container from b750fe79269d
, de1d48805de2
and 40fd00ee38e1
:
$ docker run --rm b750fe79269d cat /tmp/foo.txt cat: /tmp/foo.txt: No such file or directory $ docker run --rm de1d48805de2 cat /tmp/foo.txt foo $ docker run --rm 40fd00ee38e1 cat /tmp/foo.txt foo bar
Read full article from debugging - How can I inspect the file system of a failed `docker build`? - Stack Overflow
No comments:
Post a Comment