How do I export two containers built using docker-compose and run them on another machine?

I have one application container and one web server container. I build and run them using docker-compose. However I want to export as tar files and run them on another machine?

How can I do this while preserving the networking as defined in the compose file?

Why don’t you just start them on the other machine with the same compose file? Or is your question about exporting and importing images and volumes?

I know I can just rerun docker-compose on the other machine. Basically I’ve seen people distribute containers as downloadable tar files that contain everything inside to run the application including web server.

My question is If I wanted to do the same for an application that consist of microservices and a separate container that serves as the web server, can you bundles these all together in a single tar file, or do you have to recreate a single container that merges the functionality of the separate containers to facilitate creating a tar file.

In general though I wanted to know what the recommended approach is

yes you can: docker save -o myrelease.tar image1:tag1 image2:tag2

Add as many images as you want. Shared image layers will be included only once! Usualy this is used to transport images into air tight environments without internet access.

The recommended approach is to use an image repository. Build your images, push them to the repo and grant access to the other parties to pull the images.

1 Like