Eugene Goldberg
Eugene Goldberg

Reputation: 15564

how to package a docker image in a single file

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?

Upvotes: 15

Views: 12466

Answers (3)

Greg
Greg

Reputation: 6759

get an account on docker hub.

https://hub.docker.com/account/signup/

once signed up (only do that once), you log in from the host that has the image you want to push:

docker login
    (login with your username, password, and email address)

then you push your image up there. you probably will need to tag it first. say you created a new account called mynewacc, first, you tag your image:

docker tag ubuntu-dev-update-15 mynewacc/ubuntu-dev-update-15

then push the image up to your docker hub:

docker push mynewacc/ubuntu-dev-update-15

now anybody else with docker can pull your image down:

docker pull mynewacc/ubuntu-dev-update-15

then to run the image:

docker run -it mynewacc/ubuntu-dev-update-15 /bin/bash

you can skip the pull step, if the image doesn't exist it will be pulled anyway. the pull guarantees you get the freshest one.

Upvotes: 0

Pratik
Pratik

Reputation: 1216

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

Upvotes: 5

Tejus Prasad
Tejus Prasad

Reputation: 6500

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.

Upvotes: 40

Related Questions