2017年3月29日 星期三

Docker export and import

docker export 指令讓我們能夠將現有的image重新打包至其他docker平台上使用

使用方式如下 :

1. 先下載並執行一個centos docker image

# docker run -it centos /bin/bash

2. 進入container之後,進行任何想要的變更,並退出container

3. 查看執行狀態 (記下CONTAINER ID)

# docker ps -a
CONTAINER ID       IMAGE            COMMAND          CREATED            
0ae760c48e30            centos              "/bin/bash"              About a minute ago

3. export docker image

# docker export 0ae760c48e30 > centos.tar

4. import docker image

# cat centos.tar | docker import - centos:v1.1
sha256:e5d5c21610200d3f06f189b56bca111a54e85da0ce0ce296dbe19482738ad896
# docker images
REPOSITORY          TAG               IMAGE ID             CREATED            SIZE
centos                        v1.1                e5d5c2161020        7 seconds ago       192.5 MB

請注意:

The docker export command does not export the contents of volumes associated with the container.

所以,如果要把完整的image做export,建議使用docker save and docker load




沒有留言:

張貼留言

kubernets service 介紹

kubernets (簡稱k8s)中的容器如果要對外服務,需要透過server元件來進行 service元件有以下幾種類型可供選擇 : clusterip : 預設類型,只在k8s cluster內部IP中提供服務,外部無法訪問 nodeport : 在每個n...