I'm wondering where Docker's images are exactly stored to in my local host machine.
Can I share my Docker-Image without using the Docker-Hub
or a Dockerfile
but the 'real' Docker-Image? And what is exactly happening when I 'push' my Docker-Image to Docker-Hub?
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
Sending a docker image to a remote server can be done in 3 simple steps:
Locally, save docker image as a .tar:
docker save -o <path for created tar file> <image name>
Locally, use scp to transfer .tar to remote
On remote server, load image into docker:
docker load -i <path to docker image tar file>
Docker images are stored as filesystem layers. Every command in the Dockerfile creates a layer. You can also create layers by using
docker commit
from the command line after making some changes (viadocker run
probably).These layers are stored by default under
/var/lib/docker
. While you could (theoretically) cherry pick files from there and install it in a different docker server, is probably a bad idea to play with the internal representation used by Docker.When you push your image, these layers are sent to the registry (the docker hub registry, by default… unless you tag your image with another registry prefix) and stored there. When pushing, the layer id is used to check if you already have the layer locally or it needs to be downloaded. You can use
docker history
to peek at which layers (other images) are used (and, to some extent, which command created the layer).As for options to share an image without pushing to the docker hub registry, your best options are:
docker save
an image ordocker export
a container. This will output a tar file to standard output, so you will like to do something likedocker save 'dockerizeit/agent' > dk.agent.latest.tar
. Then you can usedocker load
ordocker import
in a different host.Host your own private registry. - Outdated, see comments
See the docker registry image. We have built an s3 backed registry which you can start and stop as needed (all state is kept on the s3 bucket of your choice) which is trivial to setup. This is also an interesting way of watching what happens when pushing to a registryUse another registry like quay.io (I haven't personally tried it), although whatever concerns you have with the docker hub will probably apply here too.
Based on this blog, one could share a docker image without a docker registry by executing:
Once this command has been completed, one could copy the image to a server and import it as follows:
If you do not want to use the Docker Hub itself, you can host your own Docker repository under Artifactory by JFrog:
https://www.jfrog.com/confluence/display/RTF/Docker+Repositories
which will then run on your own server(s).
Other hosting suppliers are available, eg CoreOS:
http://www.theregister.co.uk/2014/10/30/coreos_enterprise_registry/
which bought quay.io