複習 docker 複習及加上使用dockerfile 一鍵跑到完
匯出訂自的 image
# docker save -o <TAR_FILE> <REPOSITORY> # docker save -o <TAR_FILE> <REPOSITORY>:<TAG> docker save -o mycentos.tar mycentos docker save mycentos > mycentos.tar
匯出官方線上的 image
docker save -o centos.tar centos:latest docker save centos:latest > centos.tar docker save -o centos.tar docker.io/centos
匯入
docker load -i mycentos.tar
save 是單純將 image 匯出 (原始樣子),可以用 export 保持變動過的樣子
# 英文說明 # Save - Save one or more images to a tar archive # Ecport - Export a container’s filesystem as a tar archive docker export centos > centos.tar # import, creates one image from one tarball which is not even an image (just a filesystem you want to import as an image) # load, creates potentially multiple images from a tarred repository (since docker save can save multiple images in a tarball). docker import centos.tar centos docker export <CONTAINER ID> | docker import - some-image-name:latest
docker 的流程
# 跑一個 image docker run -it centos:cross bash # 如果要出來,用 exit 但它會讓 container EXITED # 可以用 ctrl+p and ctrl+q 出來,container 仍會是 UP 的 # UP 時可以 attach 進去 docker attach eb9aa99cf129 # 如果是 EXITED 了,就 start 它 docker start eb9aa99cf129 # 可以一開始就背景執行 docker run -d centos:cross bash # 再 exec 進入,用 exec 進入的,exit 並不會讓 container EXITED docker exec -it eb9aa99cf129 bash
留言