[英]docker_service - provisioning docker container with ansible
I use following module: 我使用以下模块:
https://docs.ansible.com/ansible/latest/modules/docker_service_module.html?highlight=ansible%20doc https://docs.ansible.com/ansible/latest/modules/docker_service_module.html?highlight=ansible%20doc
I can create and start docker container using this module. 我可以使用此模块创建和启动Docker容器。 However, is it possible to execute tasks (and preserve changes) on this container?
但是,是否可以在此容器上执行任务(并保留更改)?
I mean: 我的意思是:
install some yum package 安装一些yum包
insert some bash script into container. 在容器中插入一些bash脚本。
Could you give me some clues? 你能给我一些线索吗?
As a general rule, you don't install software on a running container. 通常,不要在正在运行的容器上安装软件。 If you need a container with some software installed in it, you should build a custom image that has the software you need, and set it up so that it can do everything it needs on its own once you start it up once.
如果您需要一个装有某些软件的容器,则应构建一个具有所需软件的自定义映像,并进行设置,以便一旦启动它即可自行完成所需的一切。 (As an even broader rule, you shouldn't need to
docker exec
into a running container except to debug things; it definitely isn't part of the core "how to do things with containers" workflow.) (作为一个更广泛的规则,除了调试之外,您无需将
docker exec
放入正在运行的容器中;它绝对不是核心的“如何对容器进行操作”工作流的一部分。)
I would recommend following a standard Docker tutorial, such as Docker's official tutorial on building and running custom images . 我建议遵循标准的Docker教程,例如有关构建和运行自定义映像的 Docker 官方教程 。 Once you have a working Docker image workflow, you'd use the Ansible
docker_container
module in place of the docker run
command. 拥有可用的Docker映像工作流程后,您将使用Ansible
docker_container
模块代替docker_container
docker run
命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.