Reputation: 41
Is there any option how to implement Docker command (--target
parameter)
docker build --target backend -t project/backend:latest
in Ansible Playbook with docker_image
module? Right now in playbook:
- hosts: localhost
tasks:
- name: Build backend image
docker_image:
path: /var/lib/workspace/project/backend
name: project/backend:latest
Upvotes: 4
Views: 7128
Reputation: 504
In the current version of Ansible it is possible to define the target in docker_image
.
Ansible Documentation - community.docker.docker_image
I think this should work for you
- hosts: localhost
tasks:
- name: Build backend image
docker_image:
path: /var/lib/workspace/project/backend
name: project/backend:latest
target: backend
When the Dockerfile is something like
FROM for-example-php-image AS baseimage
# Common things
FROM baseimage AS backend
# Things needed only in backend
Upvotes: 1
Reputation: 1241
This worked for me.
---
- name: Copy Dockerfile
copy: src=Dockerfile dest=/tmp/path/
- name: Build osquery image
docker_image:
path: /tmp/path/
name: imagename
tag: v1
Upvotes: 2