Sharing docker container
I’ve multiple docker containers that have been modified via file system updates. These updates are not represented via changes to the
This is pseudo code for process :
docker pull image docker run image docker exec -it <image_id> bash 'make changes to running docker container image exit running docker container docker commit <new container name>
To save the container I can use
docker save... and a local copy of container is saved. Can the be pushed to the registry ? Or is registry just for images and not containers ?
Is the single method of sharing a custom docker container to export it as .tar file and then re-import on other machine ?
2 Solutions collect form web for “Sharing docker container”
You never share containers, you always share images. The
docker commit command that you’ve already used does not save a container, it creates a new image from that container’s file system (documentation):
Create a new image from a container’s changes
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
You can treat an image created by
docker commit like you would any other image (create new containers from it, push it to registries, etc.).
Simply create a new image by committing an existing container, and you can push that image anywhere you want:
$ docker commit <some-running-container> yourusername/new-image $ docker push yourusername/new-image
If you do not want to use a registry, use the
docker save command to export an existing image into a file, and the
docker load command to import the image again.
$ docker commit <some-running-container> yourusername/new-image $ docker save yourusername/new-image > new-image.tar $ # On another machine: $ docker load < new-image.tar
I dont know if there is any registry exists for sharing containers. Even if there is, it would be against philosophy of docker. I cant think of a use-case where sharing images would fail but containers will succeed. Images are meant to be shared (platform independent) and containers (platform specific) will be created from those images.