Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to package a docker image in a single file

Tags:

docker

I have a 5GB docker image named "ubuntu-dev-update-15", which I developed on my local Ubuntu 14 dev machine. In that image I have everything I need to do my development work. Now I need to be able to send this image to a different linux host. What is the procedure for doing that?

like image 524
Eugene Goldberg Avatar asked Feb 05 '15 01:02

Eugene Goldberg


People also ask

Is a docker image a single file?

A Docker image has many layers, and each image includes everything needed to configure a container environment -- system libraries, tools, dependencies and other files. Some of the parts of an image include: Base image. The user can build this first layer entirely from scratch with the build command.

Can one Dockerfile build multiple images?

A multistage build allows you to use multiple images to build a final product. In a multistage build, you have a single Dockerfile, but can define multiple images inside it to help build the final image.

Can you combine 2 docker images?

Use of two commands – FROM and AS, in particular, allows you to create a multi-stage dockerfile. It allows you to create multiple image layers on top of the previous layers and the AS command provides a virtual name to the intermediate image layer.


2 Answers

If your different linux host is on the same network you can transfer saved image using FTP or local HTTP server or share to transfer the file locally. Usage of Save :

docker save [OPTIONS] IMAGE [IMAGE...]

Example : sudo docker save -o ubuntu.tar ubuntu:precise ubuntu:unicorn

where -o saves to a file, instead of STDOUT. Transfer this tar file to the other linux host.Load this tar file in the new host using: docker load [OPTIONS]

Example: sudo docker load --input fedora.tar

where --input reads from a tar archive file, instead of STDIN.

like image 174
Tejus Prasad Avatar answered Sep 30 '22 02:09

Tejus Prasad


Docker hub is one option to move your file. But from a production point of view it is better to run a registry(place to store images) in the machine where you want to send your image .

For example you want to send your image from system1 to system2. Let your image name be my_image.

Now open a registry in system1 by running

docker run -p <system1-ip>:5000:5000 -d registry

push your image into that registry :

You need to rename the image with :5000/my_image by using tag option

docker tag my_image <system1-ip>:5000/my_image

Now push into registry by using push command

docker push <system1-ip>:5000/my_image

Now go to system2 and pull your image from registry .

  docker pull <system1-ip>:5000/my_image

This is the most secured way of transferring images. Reference link creating a private repository

like image 23
Pratik Avatar answered Sep 30 '22 00:09

Pratik