It seems like the simplest question I can't find the answer for.
docker images
shows that it's present.docker images
and there's now a new image.How does one simply update the old image without creating a new one?
My docker command: docker build -t nick_app . --force-rm --no-cache
(Note: I just tossed those --force-rm command and --no-cache command' because it seemed like it would work.)
Before:
Dockerfile:
FROM ruby:2.3.3
RUN apt-get update -qq && apt-get install -y
CMD ["echo", "Sup"]
docker images command:
REPOSITORY TAG IMAGE ID CREATED SIZE
nick_app latest 421662154c3f 9 minutes ago 746.9 MB
ruby 2.3.3 d00ebde6a601 2 days ago 730.1 MB
hello-world latest c54a2cc56cbb 4 months ago 1.848 kB
After: Dockerfile:
FROM ruby:2.3.3
RUN apt-get update -qq && apt-get install -y \
build-essential
CMD ["echo", "Sup"]
docker images command:
REPOSITORY TAG IMAGE ID CREATED SIZE
nick_app latest bcf9b3667202 3 seconds ago 746.9 MB
<none> <none> 421662154c3f 10 minutes ago 746.9 MB
ruby 2.3.3 d00ebde6a601 2 days ago 730.1 MB
hello-world latest c54a2cc56cbb 4 months ago 1.848 kB
Every dockerfile change I make creates a new none
image on rebuild. They're cumulative so every time I make a change and rebuild I get another none
image.
How does one get rid of that intermediate none
every time I make a dockerfile change?
You don't need to rebuild your Docker image in development for each tiny code change. If you mount your code into your dev container, you don't have to build a new image on every code change and iterate faster. It's a great feeling when you make changes and see the results right away!
You can create a new image by using docker command $docker build -f docker_filename . , It will first read the Dockerfile where the instructions are written and automatically build the image. The instruction in the Dockerfile contains the necessary commands to assemble an image.
Those <none>:<none>
are actually the old version of your application, that has lost its named pointer, since you moved the nick_app:latest
to your new build.
When building your image, I don't think that you can tell it to destroy the old image, it will simply create a new one. But there is a command that helps you to list or remove those dangling images :
docker images --filter dangling=true #lists all images that are dangling and has no pointer to it
docker rmi `docker images --filter dangling=true -q` #Removes all those images.
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