|
15 | 15 | * [Layers](#layers)
|
16 | 16 | * [Links](#links)
|
17 | 17 | * [Volumes](#volumes)
|
18 |
| -* [Load/Save Import/Export](#loadsave-importexport) |
19 | 18 | * [Exposing Ports](#exposing-ports)
|
20 | 19 | * [Best Practices](#best-practices)
|
21 | 20 | * [Security](#security)
|
@@ -168,6 +167,35 @@ Images are just [templates for docker containers](https://docs.docker.com/engine
|
168 | 167 |
|
169 | 168 | While you can use the `docker rmi` command to remove specific images, there's a tool called [docker-gc](https://github.com/spotify/docker-gc) that will clean up images that are no longer used by any containers in a safe manner.
|
170 | 169 |
|
| 170 | +### Load/Save image |
| 171 | + |
| 172 | +Load an image from file: |
| 173 | +``` |
| 174 | +docker load < my_image.tar.gz |
| 175 | +``` |
| 176 | + |
| 177 | +Save an existing image: |
| 178 | +``` |
| 179 | +docker save my_image:my_tag > my_image.tar.gz |
| 180 | +``` |
| 181 | + |
| 182 | +### Import/Export container |
| 183 | + |
| 184 | +Import a container as an image from file: |
| 185 | +``` |
| 186 | +cat my_container.tar.gz | docker import - my_image:my_tag |
| 187 | +``` |
| 188 | + |
| 189 | +Export an existing container: |
| 190 | +``` |
| 191 | +docker export my_container > my_container.tar.gz |
| 192 | +``` |
| 193 | + |
| 194 | +### Difference between loading a saved image and importing an exported container as an image ? |
| 195 | + |
| 196 | +Loading an image using the `load` command creates a new image including its history. |
| 197 | +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. |
| 198 | + |
171 | 199 | ## Networks
|
172 | 200 |
|
173 | 201 | Docker has a [networks](https://docs.docker.com/engine/userguide/networking/dockernetworks/) feature. Not much is known about it, so this is a good place to expand the cheat sheet. There is a note saying that it's a good way to configure docker containers to talk to each other without using ports. See [working with networks](https://docs.docker.com/engine/userguide/networking/work-with-networks/) for more details.
|
@@ -333,41 +361,6 @@ You can also use remote NFS volumes if you're [feeling brave](https://web.archiv
|
333 | 361 |
|
334 | 362 | 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.
|
335 | 363 |
|
336 |
| -## Load/Save Import/Export |
337 |
| - |
338 |
| -Docker allows you to load/save images and import/export containers. |
339 |
| - |
340 |
| -### Load/Save image |
341 |
| - |
342 |
| -Load an image from file: |
343 |
| -``` |
344 |
| -docker load < my_image.tar.gz |
345 |
| -``` |
346 |
| - |
347 |
| -Save an existing image: |
348 |
| -``` |
349 |
| -docker save my_image:my_tag > my_image.tar.gz |
350 |
| -``` |
351 |
| - |
352 |
| -### Import/Export container |
353 |
| - |
354 |
| -Import a container as an image from file: |
355 |
| -``` |
356 |
| -cat my_container.tar.gz | docker import - my_image:my_tag |
357 |
| -``` |
358 |
| - |
359 |
| -Export an existing container: |
360 |
| -``` |
361 |
| -docker export my_container > my_container.tar.gz |
362 |
| -``` |
363 |
| - |
364 |
| -### Difference between loading a saved image and importing an exported container as an image ? |
365 |
| - |
366 |
| -Loading an image using the `load` command creates a new image including its history. |
367 |
| -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. |
368 |
| - |
369 |
| - |
370 |
| - |
371 | 364 | ## Exposing ports
|
372 | 365 |
|
373 | 366 | Exposing incoming ports through the host container is [fiddly but doable](https://docs.docker.com/reference/run/#expose-incoming-ports).
|
|
0 commit comments