日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

通过修改然后commit的方式创建自己的镜像

發布時間:2023/12/9 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 通过修改然后commit的方式创建自己的镜像 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

創建自己的鏡像:通過現有的鏡像來創建自己的鏡像。

1、首先拉取一個鏡像到本地
$ sudo docker images
REPOSITORY????????? TAG???????????????? IMAGE ID??????????? CREATED???????????? SIZE
ubuntu????????????? 12.04?????????????? 5b117edd0b76??????? 11 months ago?????? 104 MB

2、進入容器
$ sudo docker run -it ubuntu:12.04 bash
$ root@7a61867cf4c5:/#

3、修改容器,這里我們安裝zip包
# apt-get install zip
Reading package lists... Done
Building dependency tree????? ?
Reading state information... Done
E: Unable to locate package zip
需要更新,我們更新
root@7a61867cf4c5:/# apt-get update
結束后
root@7a61867cf4c5:/# apt-get install zip
修改后退出
root@7a61867cf4c5:/# exit
exit

4、保存容器到鏡像
$ sudo docker commit -m 'test' -a 'zhouhai' 7a61867cf4c5 ubuntu:latest
sha256:763d1f40ca6b4a801a78b39ddeb526be44330bb65f4ef94dc9267e4f0985627c
查看鏡像
$ sudo docker images
REPOSITORY????????? TAG???????????????? IMAGE ID??????????? CREATED???????????? SIZE
ubuntu????????????? latest????????????? 763d1f40ca6b??????? 13 seconds ago????? 133 MB
ubuntu????????????? 12.04?????????????? 5b117edd0b76??????? 11 months ago?????? 104 MB

5、導出新產生的鏡像
$ sudo docker save -o /home/zh/ubuntu_zip.tar ubuntu:latest

6、刪除新產生的鏡像
$ sudo docker rmi -f ubuntu:latest
Untagged: ubuntu:latest
Deleted: sha256:763d1f40ca6b4a801a78b39ddeb526be44330bb65f4ef94dc9267e4f0985627c
Deleted: sha256:e6e720db3d4ce9b5b07f4e77e6c0608add2d83b218f2b3107800682e29be246b
查看一下
$ sudo docker images
REPOSITORY????????? TAG???????????????? IMAGE ID??????????? CREATED???????????? SIZE
ubuntu????????????? 12.04?????????????? 5b117edd0b76??????? 11 months ago?????? 104 MB

7、導入剛才保存的鏡像
$ sudo docker load --input /home/zh/ubuntu_zip.tar
83c5e276e2c0: Loading layer [==================================================>] 29.82 MB/29.82 MB
Loaded image: ubuntu:latest
查看一下
$ sudo docker images
REPOSITORY????????? TAG???????????????? IMAGE ID??????????? CREATED???????????? SIZE
ubuntu????????????? latest????????????? 763d1f40ca6b??????? 16 minutes ago????? 133 MB
ubuntu????????????? 12.04?????????????? 5b117edd0b76??????? 11 months ago?????? 104 MB
進入容器
$ sudo docker run -it ubuntu:latest bash
root@9d1ab685dd74:/# zip
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
? The default action is to add or replace zipfile entries from list, which
? can include the special name - to compress standard input.
? If zipfile and list are omitted, zip compresses stdin to stdout.
? -f?? freshen: only changed files? -u?? update: only changed or new files
? -d?? delete entries in zipfile??? -m?? move into zipfile (delete OS files)
? -r?? recurse into directories???? -j?? junk (don't record) directory names
? -0?? store only?????????????????? -l?? convert LF to CR LF (-ll CR LF to LF)
? -1?? compress faster????????????? -9?? compress better
? -q?? quiet operation????????????? -v?? verbose operation/print version info
? -c?? add one-line comments??????? -z?? add zipfile comment
? -@?? read names from stdin??????? -o?? make zipfile as old as latest entry
? -x?? exclude the following names? -i?? include only the following names
? -F?? fix zipfile (-FF try harder) -D?? do not add directory entries
? -A?? adjust self-extracting exe?? -J?? junk zipfile prefix (unzipsfx)
? -T?? test zipfile integrity?????? -X?? eXclude eXtra file attributes
? -y?? store symbolic links as the link instead of the referenced file
? -e?? encrypt????????????????????? -n?? don't compress these suffixes
? -h2? show more help
大功告成!

轉載于:https://www.cnblogs.com/Micang/p/docker.html

總結

以上是生活随笔為你收集整理的通过修改然后commit的方式创建自己的镜像的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。