mirror of
https://github.com/wsargent/docker-cheat-sheet.git
synced 2025-09-21 21:30:48 +02:00
Added load save import export
Example of load/save image and import/export container. Briefly explained the difference between them
This commit is contained in:
parent
f55ecef1bb
commit
fe008736e2
1 changed files with 36 additions and 0 deletions
36
README.md
36
README.md
|
@ -15,6 +15,7 @@
|
|||
* [Layers](#layers)
|
||||
* [Links](#links)
|
||||
* [Volumes](#volumes)
|
||||
* [Load/Save Import/Export](#load-save-import-export)
|
||||
* [Exposing Ports](#exposing-ports)
|
||||
* [Best Practices](#best-practices)
|
||||
* [Security](#security)
|
||||
|
@ -332,6 +333,41 @@ You can also use remote NFS volumes if you're [feeling brave](https://web.archiv
|
|||
|
||||
You may also consider running data-only containers as described [here](http://container42.com/2013/12/16/persistent-volumes-with-docker-container-as-volume-pattern/) to provide some data portability.
|
||||
|
||||
## Load/Save Import/Export
|
||||
|
||||
Docker allows you to load/save images and import/export containers.
|
||||
|
||||
### Load/Save image
|
||||
|
||||
Load an image from file:
|
||||
```
|
||||
docker load < my_image.tar.gz
|
||||
```
|
||||
|
||||
Save an existing image:
|
||||
```
|
||||
docker save my_image:my_tag > my_image.tar.gz
|
||||
```
|
||||
|
||||
### Import/Export container
|
||||
|
||||
Import a container as an image from file:
|
||||
```
|
||||
cat my_container.tar.gz | docker import - my_image:my_tag
|
||||
```
|
||||
|
||||
Export an existing container:
|
||||
```
|
||||
docker export my_container > my_container.tar.gz
|
||||
```
|
||||
|
||||
### Difference between loading a saved image and importing an exported container as an image ?
|
||||
|
||||
Loading an image using the `load` command creates a new image including its history.
|
||||
Importing a container as an image using the `import` command creates an new image excluding the history which results in a smaller image size compared to loading an image.
|
||||
|
||||
|
||||
|
||||
## Exposing ports
|
||||
|
||||
Exposing incoming ports through the host container is [fiddly but doable](https://docs.docker.com/reference/run/#expose-incoming-ports).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue