Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to import export docker compose?

I am still new in docker and all container things. I have server with full access at 1.1.1.1 and I installed docker there. (without docker compose) In the other place my friend have server 2.2.2.2 and he installed docker and docker compose there.

At 2.2.2.2 server, my friend build 3 container : container A (Git), container B(unknown), container C(unknown). I can access content of container A (Git) with browsers.

My question is: can I import container A to my server in 1.1.1.1? I have user access to download Git, but what I want is to import the container, not Git (content inside the container). Any hint? what should I do? Or it is impossible to do if I don't have access to the command console?

like image 226
ivanprakasa Avatar asked May 21 '26 05:05

ivanprakasa


1 Answers

If you want to move the running container instance then I would recommend you to run the below command

$ docker ps
 CONTAINER ID    IMAGE             COMMAND       CREATED       STATUS       NAMES
 c3f279d17e0a   ubuntu:12.04      /bin/bash      7 days ago    Up 25 hours desperate_dubinsky
 197387f1b436   ubuntu:12.04      /bin/bash      7 days ago    Up 25 hours focused_hamilton

$ docker commit c3f279d17e0a  svendowideit/testimage:version3

This would create the image on the host machine and then run the below command to save the image as tar file to upload it into another host.

$ docker save -o testimage.tar svendowideit/testimage:version3

On scp the tar image to another host run the below command to extract the tar and save it as docker images.

 $ docker images
 REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

 $ docker load --input testimage.tar
 Loaded image: svendowideit/testimage:version3

 $ docker images
 REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
 svendowideit/testimage version3            769b9341d937        7 weeks ago         2.489 MB

Now you can make use of docker run command to bring up the docker instance of the saved images.

like image 87
Viswesn Avatar answered May 22 '26 19:05

Viswesn