I want to distribute a Docker Compose system as a single archive. For this I want to run docker save
on all the images. But how do I get the list of images from Docker Compose?
This is what I do at the moment:
IMAGES=$(cat docker-compose.yml | sed -n 's/image:\(.*\)/\1/p')
docker save -o images.tar $IMAGES
Here is a solution using docker compose convert
. This is helpful, as it will expand any environment variables used to define your images in the compose file.
IMAGES=( $(docker compose convert --images) )
docker save ${IMAGES[@]} | gzip > images.tar.gz
Do the following:
# Save Compressed Images
IMAGES=`grep '^\s*image' docker-compose.yml | sed 's/image://' | sort | uniq`
docker save $IMAGES | gzip > images.tar.gz
# Load Compressed Images
gunzip -c images.tar.gz | docker load
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