2

I don't have much experience with Docker so not sure if this is even possible, but I'm trying to export my Docker containers as a single image.

I've created a web server using various images from the official repos (nginx, php7, postgresql). I have a docker-compose.yml file to start each container and link them.

There are volumes for the web hosting root directory and the postgresql data directories.

I now need to export this whole lot, including the volumes so that our technicians out in the field can easily install our web server on client networks. We generally do not have access to the internet on those PCs which is why I can't simply give them the compose and Dockerfiles.

Apologies if I'm not being clear but this is still pretty new to me.

web: image: nginx:latest environment: - DOCKER_WEB=true #stdin_open: true #tty: true ports: - "8080:80" volumes: - ./code:/code - ./default.conf:/etc/nginx/conf.d/default.conf links: - php cron: build: './docker/cron' links: - web throwaway: build: './docker/throwaway' volumes: - ./code:/code php: #image: php:7-fpm build: './docker/php' links: - postgres volumes: - ./code:/code postgres: image: postgres:latest environment: - POSTGRES_USER=un_rftags - POSTGRES_PASSWORD=pwd_RFT@gs01 - POSTGRES_DB=db_rftags volumes: - ./postgres-data:/var/lib/postgresql/data ports: - "9090:5432" 

2 Answers 2

3

You can save all your images at once with docker save, and then import them on the destination system with docker load.

This means, of course, that you need to create images, but you seem to be doing that already.

For example:

docker save nginx:latest cron throwaway php | xz -c > all-images.tar.xz 

Import them to the destination docker with:

xz -dc < all-images.tar.xz | docker load 
2

To move the image onto the client system you'd use docker save and docker load like so:

  • Save all images that are used within your docker compose:
    • cd path/where/your/docker-compose.yml/is/located
    • docker save -o docker_images.tar $(docker compose config --images) (Source)
  • Sent resulting .tar file alongside your docker-compose.yml to the technician
  • Let the technician load the .tar and run your services:
    • docker load -i docker_images.tar
    • cd path/to/docker-compose/-directory
    • docker compose up -d

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.