![docker run image from tar docker run image from tar](https://onurdesk.com/wp-content/uploads/2020/10/dockerfile.png)
docker import my-container.tar my-image:latest
#Docker run image from tar archive#
Instead, importing a container archive constructs a new image. As a container represents a live, running environment, you can’t “import” one directly. However, container archives don’t import in the way you might first expect. docker load my-container.tarĭocker export is useful if you want to snapshot a container for later restoration. Docker will load the archive’s contents and add it to your list of local images. This accepts a tar archive produced by docker save as an input stream. To use an exported image, run the docker load command. Archives could be quite large so you’ll usually be best off by uploading it to a file server or a cloud storage provider. The archive will also contain information on tags associated with the image.Īs the output is a simple tar file, you’re now free to distribute it in whichever way you choose. Docker will include everything needed to recreate the image – that’s all the layers in your Dockerfile, as well as the layers inherited from your base image. The export might take a few moments to complete.
![docker run image from tar docker run image from tar](https://www.omnis.net/developers/resources/technotes/images/docker3.png)
Build your image and then use the docker save command to get a tar archive of its contents: docker save my-image:latest > my-image.tar This functionality is also built into the Docker CLI. If using a registry isn’t an option, you can manually export Docker image archives instead. This lets you easily share images with anyone who can access your private registry. You can create a self-hosted registry server instead to get private storage that’s fully compatible with the docker push and docker pull commands. If you’re part of a development team, you’ll probably want to keep images on your own server, instead of the public Hub registry. You’re done sharing your image!įor real-world use, Docker Hub might not be sufficient. Other users will be able to pull it down using the docker pull or docker run commands. Now your image is safely stored in Docker Hub. Then use the docker push command to push the tagged image up to Docker Hub: docker push my-account/my-image:latest