我想用 ansible 剧本替换这个命令
'docker build -q --network host -t "ubuntu" . '
我一直在浏览ansible的docker_image模块,但无法弄清楚。知道如何进一步进行吗?
提前致谢。
距离您最近的地方是:
---
- name: build the image
docker_image:
name: docker
tag: ubuntu
path: "/yourpath"
state: present
对于 --network 主机,在 Github 中打开了一个请求来获取它。
您只需将
network_mode: host
添加到您的 docker_container
任务即可。这是一个工作示例:
---
- name: deploy whoami
hosts: docker01
become: true
tasks:
- name: install whoami server
docker_container:
name: whoami
image: traefik/whoami
state: started
recreate: true
network_mode: host