要在Ansible中跳过Docker构建,可以使用docker_image
模块的build
参数来指定跳过构建。以下是一个示例代码:
- name: Skip Docker build
hosts: localhost
gather_facts: false
tasks:
- name: Pull Docker image
docker_image:
name: some_image
source: pull
state: present
- name: Skip Docker build
docker_image:
name: some_image
build: false
state: present
在上面的示例中,首先使用docker_image
模块的source
参数来拉取一个Docker镜像。然后,通过将build
参数设置为false
,来告诉Ansible跳过Docker构建。
请注意,上述示例假设已经在本地主机上安装了Docker,并且可以通过Ansible访问Docker守护程序。如果您尚未安装Docker,请先安装Docker,并确保Ansible可以访问Docker守护程序。
上一篇:Ansible跳过$的伪目标
下一篇:Ansible条件 - 多主机