首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何创建Ubuntu (运行)基础镜像以在其他环境中复制。

如何创建Ubuntu (运行)基础镜像以在其他环境中复制。
EN

Stack Overflow用户
提问于 2017-02-09 04:13:01
回答 1查看 58关注 0票数 0

我有两个问题关于如何从我正在运行的Ubuntu和工作项目目录中构建docker镜像到带有版本的基础镜像

1)如何在我运行的Ubuntu (14.0.4)中创建基础镜像。它有MongoDB和其他必需的依赖项来支持我们的应用程序。

2)基于之前的镜像,希望为应用程序(项目目录)创建基础镜像,以创建用于部署的zed版本镜像。

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2017-02-09 04:41:47

您可以使用docker commit将容器转换为图像

代码语言:javascript
运行
复制
# start a new ubuntu container, change some things and stop it again
$ docker run -it ubuntu
root@ca93ddb728ae:/# echo "changed image" > file
root@ca93ddb728ae:/# cat /file 
changed image
root@ca93ddb728ae:/# exit
exit

# the container still exists but it's stopped now
# turn it's current state into an image called 'my-ubuntu-image'
$ docker commit ca93ddb728ae my-ubuntu-image
sha256:47b71ccc78ae0b54598f153b1c999c01a9039b654e90da3a3ef3514b2f987df0

# start a container of our new 'my-ubunut-image' and find the previously
# changed file
$ docker run -it my-ubuntu-image
root@2732f428bf8a:/# cat /file 
changed image

在此之后,您可以像以前一样使用新映像构建新映像。但是,建议使用Dockerfile来创建映像。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42122744

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档