是否有任何选项可以实现Docker命令(--target
参数)
docker build --target backend -t project/backend:latest
在带有docker_image
模块的Ansible Playbook中的?现在在剧本中:
- hosts: localhost
tasks:
- name: Build backend image
docker_image:
path: /var/lib/workspace/project/backend
name: project/backend:latest
答案 0 :(得分:0)
这对我有用。
---
- name: Copy Dockerfile
copy: src=Dockerfile dest=/tmp/path/
- name: Build osquery image
docker_image:
path: /tmp/path/
name: imagename
tag: v1
答案 1 :(得分:0)
在当前版本的 Ansible 中,可以在 docker_image
中定义目标。
Ansible Documentation - community.docker.docker_image
我认为这对你有用
- hosts: localhost
tasks:
- name: Build backend image
docker_image:
path: /var/lib/workspace/project/backend
name: project/backend:latest
target: backend
当 Dockerfile 类似于
FROM for-example-php-image AS baseimage
# Common things
FROM baseimage AS backend
# Things needed only in backend