It’s quite easy to pull images via
docker down to your local developer machine. But sometimes you need to get images onto servers which have no access to the World Wide Web (WWW) nor to an internal docker registry. In this article I show you how to use
docker save and
docker load to get the required images onto those servers.
Setup test environment
First of all we’re going to make sure, that no
sudo is required to run
docker. If you know what you’re doing or don’t want to change your local setup, you can safely skip this section and go on with the next one, but maybe not all commands will work as expected. Please, add your local user to the
# Add user to group gpasswd -a <user> docker
After that, either logout/login or update your current group to
docker with the following command. This command will start a new shell with the docker group being your primary group. So this one is only a temporary “change of group” local to that shell.
# Start shell with new primary group newgrp docker
Please, check if your groups have been updated. The output you get should be similar to the following.
# Check groups id # => uid=1002(test1) gid=142(docker) groups=142(docker),1006(test1)
Now pull the image you need at your isolated remote system, down to your local machine. This assumes, that your machine has unlimited access to the WWW.
If you’re using “Arch Linux” and need to use a proxy, create a file named
http_proxy=http://<proxy>:<port>to this file. Now copy
.service-file. After that run
sudo systemctl daemon-reloadand
sudo systemctl restart docker.
If you’re behind a proxy, make sure, that “docker” works in such an environment and can pull the image.
# Pull docker image docker pull feduxorg/centos
After that, export the downloaded image to a
tar.gz-file. It’s important to use
docker save here, because this also exports the metadata like the
ENV. Even the name of the image “feduxorg/centos” is exported.
# Save image docker save -o image.tar.gz feduxorg/centos
Transfer image to destination
If this has finished, transfer the image to the isolated system. I’m going to use
scp (SSH) for this. You may need to use a different tool depending on your environment – or even a USB-stick, an SD-card or a DVD.
# Uplodate image to "host" scp image.tar.gz <host>:~/
After that, login to your remote system and import the image there. Please make sure, that your user is also member of the
docker-group on the remote system. You can re-use the commands used earlier on your local workstation.
# Login to remote system ssh <host> # Import image docker load -i image.tar.gz
That’s it. Easy, isn’t it? I regularly forget about
save and use
export instead. The same happens with
import don’t work with meta data which is something I always want to be exported/imported. After using
ENTRYPOINT of your image are gone. So this article is a reminder for you and me to prevent frustration. Hope this helps you as well.
Thanks for reading!
DiscussionIf you found a mistake in this article or would like to contribute some content to this article, please file an issue in this Git Repository
DisclaimerThe contents of this article are put together to the best of the authors' knowledge, but it cannot be guaranteed that it's always accurate in any environment. It is up to the reader to make sure, that all information found in this article, does not do any damage to the readers's working environment or whereever this information is applied to. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, arising from, out of or in connection with this article. Please also note the information given on the Licenses' page.
- Break it Baby, break it – How the network sniffer "Wireshark" can break Rubygems
- Having No Fun with Rubygems, Systemd, Docker and Networking
- Creating an IRB-based Read-Eval-Print-Loop-console for your project
- Setting up a Ruby-based HTTP-server to back your test suite
- Setting up an HTTP proxy with ruby