Docker 如何创建Ubuntu(正在运行)基本映像以在其他环境中复制。

Docker 如何创建Ubuntu(正在运行)基本映像以在其他环境中复制。,docker,Docker,我有两个问题,关于如何从我正在运行的Ubuntu和工作的项目目录构建docker映像到具有版本的基本映像 1) 如何从我运行的Ubuntu(14.0.4)创建基本映像。它有MongoDB和其他必需的依赖项来支持我们的应用程序 2) 基于上一个映像,要为应用程序(项目目录)创建基础映像,以创建用于部署的版本化映像 提前谢谢 您可以使用docker commit将容器转换为图像: # start a new ubuntu container, change some things and stop

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

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

2) 基于上一个映像,要为应用程序(项目目录)创建基础映像,以创建用于部署的版本化映像


提前谢谢

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

# 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
之后,您将像以前一样使用新图像来构建新图像。但是,建议使用创建图像的方法是使用