Wednesday, April 13, 2022

[SOLVED] How to start docker containers using images loaded from another server?

Issue

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?


Solution

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

So you need two things

1: tar file having multiple images

2: docker-compose file to describe how each image should load.

Ref: Exporting Multiple Docker Images Alongside Docker-Compose



Answered By - Gupta
Answer Checked By - Terry (WPSolving Volunteer)