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
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With