Jay
Jay

Reputation: 782

Moving my Docker application which is a collection of containers

I have been reading various articles for migrating my Docker Application into a different machine. All the articles talk about “docker commit” or “export/ import”. This only refers to a single Container, which is first converted to an Image and then we do a “docker run” on the new machine.

But my application is usually made up of several containers, because I am following the best practice of segregating different services.

The question is, how do I migrate or move all the containers that have been configured to join together and run as one. I don’t know whether “swarm” is the correct term for this.

The alternative I see is - simply copy the “docker-compose” and “dockerfile” into the new machine and do a fresh setup of the architecture. Then I copy all the application files. It runs fine.

Upvotes: 0

Views: 146

Answers (2)

Anna Bear
Anna Bear

Reputation: 9

I agree to the docker-compose suggestion. And to store your images in a registry or on your local machine. Each section in your docker compose file will be separated per service. Each service will have to be written in YAML format.

You are going to want version 3 YAML I believe. Then from there you code something like below. But each service will use your Dockerfile image in your registry or locally in your folder.

version : '3'

services: 

  drupal:
    image:

         ......ports, volumes, etc 

   postgres:
     image: 

           ......ports, volumes, etc 

Disclosure: I took a Docker Course from Bret Fisher on Udemy.

Upvotes: -1

Alejandro Galera
Alejandro Galera

Reputation: 3691

My purpose, of course is not the only solution, but it's quite nice:

  1. Create docker images in one machine (where you need your Dockerfile)

  2. Upload images to a docker registry (you can use your own docker hub account, or maybe a nexus, or whatever)

    2.1. It's also recommended to tag with version your images, and protect overwritting an image with the same version and different code.

  3. Use docker-compose (it's recommended define a docker network for all docker that have to interact among them) to deploy (docker-compose up is like several docker run, but easier to mantain.)

  4. You can deploy in several machines just using the same docker-compose.yml to deploy and access to your registry.

    4.1. Deploy can be done in a single host, swarm, kubernetes... (you'd have to translate your docker-compose.yml to kubectl yml file for that)

Upvotes: 2

Related Questions