Skip to content

docker_image doesn't not support Docker BuildKit #514

@allen12921

Description

@allen12921
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\")"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bugmodulemodule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions