mirror of
https://github.com/yeasy/docker_practice.git
synced 2025-08-08 08:11:59 +00:00
Fix issue#6: clarify the differences between image:save,load and container:export,import
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
##导出和导入镜像
|
||||
|
||||
###导出镜像
|
||||
如果要导出本地的镜像到文件,可以使用`docker export`命令。
|
||||
```
|
||||
$sudo docker ps -a
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
7691a814370e ubuntu:14.04 "/bin/bash" 36 hours ago Exited (0) 21 hours ago test
|
||||
$sudo docker export 7691a814370e > ubuntu.tar
|
||||
|
||||
```
|
||||
|
||||
*注意:也可以使用`docker save`命令导出一个镜像,它会记录从基础镜像到目前状态的所有历史记录,文件体积较大。
|
||||
|
||||
###导入镜像
|
||||
可以使用`docker import`从导出的本地文件中再导入镜像,例如
|
||||
```
|
||||
$cat ubuntu.tar | sudo docker import - test_repo/localubuntu:v1.0
|
||||
```
|
||||
|
||||
此外,也可以通过指定URL或者某个目录来导入,例如
|
||||
```
|
||||
$sudo docker import http://example.com/exampleimage.tgz example/imagerepo
|
||||
```
|
||||
|
24
image/save_load.md
Normal file
24
image/save_load.md
Normal file
@@ -0,0 +1,24 @@
|
||||
##存出和载入镜像
|
||||
|
||||
###存出镜像
|
||||
如果要导出镜像到本地文件,可以使用`docker save`命令。
|
||||
```
|
||||
$sudo docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||
ubuntu latest 826544226fdc 2 weeks ago 194.2 MB
|
||||
ouruser/sinatra v2 51619aaca804 2 weeks ago 373.3 MB
|
||||
ubuntu 14.04 c4ff7513909d 5 weeks ago 225.4 MB
|
||||
$sudo docker export ubuntu:14.04 > ubuntu_14.04.tar
|
||||
```
|
||||
|
||||
|
||||
###载入镜像
|
||||
可以使用`docker load`从导出的本地文件中再导入到本地镜像库,例如
|
||||
```
|
||||
$sudo docker load --input ubuntu_14.04.tar
|
||||
```
|
||||
或
|
||||
```
|
||||
$sudo docker load < ubuntu_14.04.tar
|
||||
```
|
||||
这将导入镜像以及其相关的元数据信息(包括标签等)。
|
Reference in New Issue
Block a user