Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker_image doesn't not support Docker BuildKit #514

Closed
allen12921 opened this issue Jun 15, 2020 · 4 comments
Closed

docker_image doesn't not support Docker BuildKit #514

allen12921 opened this issue Jun 15, 2020 · 4 comments
Labels
bug This issue/PR relates to a bug module module

Comments

@allen12921
Copy link

SUMMARY

docker_image doesn't not support Docker BuildKit

ISSUE TYPE
  • Bug Report
COMPONENT NAME
ANSIBLE VERSION
ansible 2.9.5
CONFIGURATION
ANSIBLE_SSH_ARGS(/etc/ansible/ansible.cfg) = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s
OS / ENVIRONMENT

target OS versions: CentOS Linux release 7.8.2003 (Core)
Docer version: 19.03.9

STEPS TO REPRODUCE

With Below content Dockerfile:

#syntax=docker/dockerfile:experimental
FROM alpine
RUN apk add --no-cache openssh-client git
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
RUN --mount=type=ssh git clone git@github.com:myorg/myproject.git myproject

Then build image with docker_image

  - name: build and push rails image
    docker_image:
      name: "test"
      build: 
        dockerfile: Dockerfile
        path: "test"
        pull: yes
      push: yes
      source: build
      force_source: yes
    delegate_to: "localhost"
ansible-playbook    buikd.yml
EXPECTED RESULTS

the test image will be build

ACTUAL RESULTS

not recognize the mount option when build with ansible while I can build success by running docker build command directly

fatal: [localhost -> localhost]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "An unexpected docker error occurred: 400 Client Error: Bad Request (\"Dockerfile parse error line 5: Unknown flag: mount\")"}

@felixfontein
Copy link
Collaborator

This is not a bug in Ansible. The module simply sends the build request to the Docker daemon (via the Docker SDK for Python), and the daemon is returning this error.

@ansibullbot ansibullbot added affects_2.10 bug This issue/PR relates to a bug labels Jun 15, 2020
@felixfontein
Copy link
Collaborator

felixfontein commented Jun 15, 2020

If docker-py ever supports this (see docker/docker-py#2230), we can add support for it as well. Anyway, this is a feature request, not a bug report.

!component =plugins/modules/cloud/docker/docker_image.py

@allen12921
Copy link
Author

close as docker-py not support

spantaleev added a commit to spantaleev/matrix-docker-ansible-deploy that referenced this issue Jan 26, 2022
Synapse v1.51.0 requires to be built with BuildKit since
matrix-org/synapse#11691

The `docker_image` Ansible module does not support BuildKit
(ansible-collections/community.general#514),
so we had to switch to a `docker build` call.
HarHarLinks pushed a commit to HarHarLinks/matrix-docker-ansible-deploy that referenced this issue Feb 16, 2022
Synapse v1.51.0 requires to be built with BuildKit since
matrix-org/synapse#11691

The `docker_image` Ansible module does not support BuildKit
(ansible-collections/community.general#514),
so we had to switch to a `docker build` call.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module
Projects
None yet
Development

No branches or pull requests

3 participants