I have a docker-compose.yml file which builds new images as per its instruction and is working fine
now i wants to move only this images to another machine
how can i do so ?
i am able to save single image using docker save command but how can i save multiple images generated from docker-compose ? and use it another machine ?
I would suggest to setup a private image repository (Gitlab, Nexus3, Artifactory Container Registry, Harbor…) and push the images to the private image repository. Other hosts can pull the images from there.
If this is not applicable for you, then you can use a list of tags in the docker save
operation:
docker save -o ubuntu.tar ubuntu:lucid ubuntu:saucy
In this case ubuntu.tar
is the target file holding the saved images of ubuntu:lucid
and ubuntu:saucy
. You can add as many tags to the list as you want.
Though, when you import them, you can not cherry pick, which ones to import. It will always import all images.
Loading this file will build two new individual images
I want to build only single image from my docker-compose file
so that I can run it on another machine as single container
is there anyway to achieve this ?
Surely you build only once, which is conveniently a best practice in Continuous Delivery.
Services are built once and then tagged, by default as
project_service
. For example,composetest_db
. If the Compose file specifies an image name, the image is tagged with that name
If you ran docker-compose up
on your machine, it did the build.
Check the images by docker images
command.
Then you can use docker tag ...
to tag your image with the external name coming from external Registry, and then docker push ..
it there.
Do not use docker save
for what you want to achieve.
It is some confidential code so i cant push to dockerhub
with docker save i need to save both image and run both of this image on another computer
any other way that i can combine this two images into one and run only one image on my server ?
That’s what I answered above.
Image is created by docker-compose build
or behind the scenes by docker-compose up
.
You just push it to your Docker Registry (not GitHub).
It’s a single image, no need for a second one.