Not entirely sure what I am asking but I will attempt to try and explain what I want.
I have a docker-compose
file. And from the command line I type in...
docker-compose up
The first time this ever happens it tells me it is pulling
the docker image and then downloading
it, building
it and running
it.
Sometimes I need to change the docker-compose file and I would like to just re-do the entire process (as specified above).
But.... the only way I can see to do this is to go the the GUI of docker (on mac) and hit the bomb
icon to factory reset the entire thing.
Of course this nukes my other docker images (which feels like a sledgehammer to crack a nut).
Can anybody furnish me with a command that will reset and force and entire fresh download of an image?
So my understanding of what you're asking for is to be able to make the very first run of a docker compose up
operation repeatable
So docker provides the following commands:
docker images <image_name>
This lists all the images for a given name. It works with wildcards too, so if all your images are prefixed then docker images my_app*
works
To get just the image ids, you use docker images <image_name> -q
... this gives just the image id ... you can go docker images <image_name> golang -q && docker images postgres
as an example to list your image ids
Now you take those ids and use docker rmi <image_id>
which will delete the image.
TL;DR;
So putting it all together you go:
docker rmi `docker images <image_name> -q && docker images <image_name> -q`
I think the backtick technique will work in OSX (under bash), but if it doesn't you just want to evaluate the image ids first before docker rmi
is called. Let me know and I'll remove this paragraph.
Note that this will only remove your images, if you have volumes attached you may need to remove those as well. I think docker-compose down -v
does this for you, but I need to confirm a bit later when I tidy the answer up.
docker build -t ignitus-rest:latest .
will do the job :)
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