首页 > 其他 > 详细

Docker 镜像添加模块

时间:2019-12-24 18:52:04      阅读:113      评论:0      收藏:0      [点我收藏+]

Docker 镜像添加模块

 
技术分享图片

1. 使用root用户进入一个新容器,不要用 --rm .否则退出容器的时候,容器没有了

docker run --user 0 -it --name superman testdockerfilebox/test_cpu:latest bash

2. 在容器中添加你要的功能,然后退出容器

apt install ...
npm install -g n 
pip3 install ...

3. commit 刚才操作的容器成 image (testdockerfilebox/test_cpu:v1 名称和版本号可以自己定义)

docker commit superman testdockerfilebox/test_cpu:v1

4. 查看刚才 commit 操作的 image, 此时 image 里面就包含了刚才添加的新增的模块了

root@test:~# docker images 

REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE

testdockerfilebox/test_cpu           v1                  e4f2c829d1eb        23 minutes ago      4.42GB

5. 将新的 image 保存成 tar 压缩文件,给其他人使用,统一开发环境

docker save testdockerfilebox/test_cpu:v1 -o test_cpu.tar

6. 别人拿到 test_cpu.tar 文件后使用 docker load 加载 image

docker load -i test_cpu.tar

此时使用 docker images 就可以看到刚才的导入的 image 了

root@test:~# docker images 

REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE

testdockerfilebox/test_cpu          v1                  e4f2c829d1eb        23 minutes ago      4.42GB

 

Docker 镜像添加模块

原文:https://www.cnblogs.com/musen/p/12092726.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!