Is there a way to seamlessly transfer docker-compose containers to another host without building? [duplicate]

I'm setting up a CI/CD solution. I would like to run a docker application on a production machine that has no access to the internet.

The constraints are as follows:

  • Build needs to happen on machine A

  • Resulting image/container needs to be exported and transported to machine B

Optionally: Run the container again with a docker-compose file

I know about docker commit and repos, but this is sadly not an option, as the resulting server does not have access to the internet.

Here's the docker-compose.yaml; this is not set in stone and can change however necessary

version: '2'
services:
  test_dev_app:
    image: testdevapp:latest
    container_name: test_dev_app
    hostname: test_dev_app
    environment:
      DJANGO_SETTINGS_MODULE: "settings.production"
      APPLICATION_RUN_TYPE: "uwsgi"
    volumes:
      - ./:/data/application
    ports:
      - "8000:8000"
      - "8080:8080"

I'd expect to be able to properly transport a container or image and use the same image on a different machine with docker-compose up


Esteban is right about how to do it the registry way, but forgot to mention the "tar" way : you can basically save an image to a tar archive, then later load it to the docker inner registry of another one.
The way to transport the image is up to you!

Still, if you plan to do it often, I recommand following the private registry solution: it's definitely cleaner!


P̶u̶s̶h̶i̶n̶g̶ ̶D̶o̶c̶k̶e̶r̶ ̶i̶m̶a̶g̶e̶s̶ ̶t̶o̶ ̶a̶ ̶r̶e̶g̶i̶s̶t̶r̶y̶ ̶i̶s̶ ̶t̶h̶e̶ ̶o̶n̶l̶y̶ ̶w̶a̶y̶ ̶(̶a̶t̶ ̶l̶e̶a̶s̶t̶ ̶s̶u̶p̶p̶o̶r̶t̶e̶d̶ ̶b̶y̶ ̶d̶o̶c̶k̶e̶r̶ ̶o̶u̶t̶-̶o̶f̶-̶t̶h̶e̶-̶b̶o̶x̶)̶ ̶t̶o̶ ̶s̶h̶a̶r̶e̶ ̶t̶h̶e̶m̶ ̶b̶e̶t̶w̶e̶e̶n̶ ̶s̶e̶r̶v̶e̶r̶s̶.

If internet access is not an option, then take a look at having your own private docker registry.

Deploy it in a network segment accessible from both the pushing and pulling machine.

Then build your docker image including your registry's address and push it:

docker build -t <private_registry_address>/test_dev_app:latest .
docker push <private_registry_address>/test_dev_app:latest

When you push it the docker client will know that it has to use the specified address instead of the public registry.

Or as mentioned by tgogos on the comment below check his link on how to use docker save / docker load on air-gapped environments.