Home > other >  How to start docker containers using images loaded from another server?
How to start docker containers using images loaded from another server?

Time:03-10

I have a project which consists of several services which are defined in a docker-compose.yaml file.

When I run docker-compose up -d several docker images are created and then each service runs in its own container.

I have followed the steps here How to save all Docker images and copy to another machine in order to save the images so that I can use them on another customer PC.

I ran this to save the images:

sudo docker save $(sudo docker images | sed '1d' | awk '{print $1 ":" $2 }') -o  my_project.tar 

And I can load this by doing:

sudo docker load -i my_project.tar

This appears to have saved and loaded the images as I check with the following command and all the imaegs do appear with the correct names and tags:

sudo docker images

But at this point there are no contianers running. How do I actually start each container the same way they were started with the docker-compose up command when using the original project?

CodePudding user response:

The important part of this is that you must copy the docker-compose.yml file to the target system.

So you need two things 1: tar file having multiple images 2: a docker-compose file to describe how each image should load.

Ref: Exporting Multiple Docker Images Alongside Docker-Compose

CodePudding user response:

You can go with command docker run [image name] , to start container of that image with normal conditions. Many times other parameters are required while running the container like port number which can be configured after looking into docker-compose file. It would be easier and more portable if you could transfer the docker-compose file and then try to run it directly instead of transferring images and running them.

  • Related