
上QQ阅读APP看书,第一时间看更新
Saving and loading images
The third way to create a new container image is by importing or loading it from a file. A container image is nothing more than a tarball. To demonstrate this, we can use the docker image save command to export an existing image to a tarball, like this:
$ docker image save -o ./backup/my-alpine.tar my-alpine
The preceding command takes our my-alpine image that we previously built and exports it into a file called ./backup/my-alpine.tar.
If, on the other hand, we have an existing tarball and want to import it as an image into our system, we can use the docker image load command, as follows:
$ docker image load -i ./backup/my-alpine.tar
In the next section, we will discuss how we can create Docker images for existing legacy applications, and thus run them in a container, and profit from this.