Reputation: 2165
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?
Upvotes: 22
Views: 13054
Reputation: 21
You can use:
docker build -t nick_app . --force-rm --no-cache && docker image prune -a --force
Upvotes: 1
Reputation: 3879
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.
Upvotes: 21