新的Docker - 如何基本上做一个可克隆的设置? [英] New to Docker - how to essentially make a cloneable setup?

查看:689
本文介绍了新的Docker - 如何基本上做一个可克隆的设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是使用Docker创建运行postfix + dovecot的邮件设置,完全配置并准备就绪(在Ubuntu 14.04上),因此我可以轻松部署在多个服务器上。据我了解Docker,这样做的过程是:


  1. 旋转一个新的容器( docker run -it ubuntu bash )。

  2. 安装并配置后缀和dovecot。

  3. 如果我需要关闭一个休息,我可以退出shell并通过 docker start< id> 返回到容器,后跟 docker attach< id>

(这里的东西对我来说模糊)



在这一点上,最好将图像导出到文件,在其他服务器上导入并运行它?运行它后,如何确保容器会自动启动postfix,dovecot和其他服务?我也不太明白使用Dockerfile来自动安装的区别,而不是手动安装它并导出图像。

解决方案


  1. 使用Dockerfile 配置多个docker图像



    每个docker容器只能运行一个服务。所以一个postfix容器,另一个服务等等。你可以让你的运行容器相互通信


  2. 构建这些图像


  3. 将这些图像推送到注册表,以便您可以轻松地将它们拉到不同的服务器上,并进行相同的设置。


  4. 您可以在启动容器进行配置时传递ENV变量。


不要直接在正在运行的容器中安装东西。
这使得Docker可以重复设置的玩家失败。


My goal is to use Docker to create a mail setup running postfix + dovecot, fully configured and ready to go (on Ubuntu 14.04), so I could easily deploy on several servers. As far as I understand Docker, the process to do this is:

  1. Spin up a new container (docker run -it ubuntu bash).
  2. Install and configure postfix and dovecot.
  3. If I need to shut down and take a break, I can exit the shell and return to the container via docker start <id> followed by docker attach <id>.

(here's where things get fuzzy for me)

At this point, is it better to export the image to a file, import on another server, and run it? How do I make sure the container will automatically start postfix, dovecot, and other services upon running it? I also don't quite understand the difference between using a Dockerfile to automate installations vs just installing it manually and exporting the image.

解决方案

  1. Configure multiple docker images using Dockerfiles

    Each docker container should run only one service. So one container for postfix, one for another service etc. You can have your running containers communicate with each other

  2. Build those images

  3. Push those images to a registry so that you can easily pull them on different servers and have the same setup.

  4. Pull those images on your different servers. You can pass ENV variables when you start a container to configure it.

You should not install something directly inside a running container. This defeat the pupose of having a reproducible setup with Docker.

这篇关于新的Docker - 如何基本上做一个可克隆的设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆