for-linux icon indicating copy to clipboard operation
for-linux copied to clipboard

buildkit support for http api, implemented or not?

Open piwinkler opened this issue 5 years ago • 2 comments

  • [?] This is a bug report
  • [?] This is a feature request
  • [x] I searched existing issues before opening this one

Expected behavior

I stumpled up on this feature "Using SSH to access private data in builds" (https://docs.docker.com/develop/develop-images/build_enhancements/#using-ssh-to-access-private-data-in-builds) and it's nice, what i wanted and it works well via cli. So i expected it to work via the http api as well, it doesn't. It says here (https://docs.docker.com/engine/reference/commandline/build/#options) that this is available with version 1.39+ of the api, i am using 1.40.

Actual behavior

The response is

{"message":"Dockerfile parse error line 3: Unknown flag: mount"}

Steps to reproduce the behavior

I used a simple curl request:

curl -v -X POST -H "Content-Type:application/x-tar" --data-binary '@Dockerfile.tar.gz' http://*.*.*.*:2375/build?t=build_test

and my Dockerfile looks like this:

# syntax=docker/dockerfile:experimental
FROM php:7.2 as composer
RUN --mount=type=ssh mkdir /workdir/

Output of docker version:

Client: Docker Engine - Community
 Version:           19.03.13
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        4484c46d9d
 Built:             Wed Sep 16 17:02:55 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.13
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       4484c46d9d
  Built:            Wed Sep 16 17:01:25 2020
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.3.7
  GitCommit:        8fba4e9a7d01810a393d5d25a3621dc101981175
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker info:

Client:
 Debug Mode: false

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 19.03.13
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.19.0-12-amd64
 Operating System: Debian GNU/Linux 10 (buster)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 7.792GiB
 Name: ***
 ID: QB4K:OLTR:IPFS:C5RJ:QAS6:MPNB:P3LL:57EQ:C2Y7:GV5D:XZEJ:6K6U
 Docker Root Dir: /opt/docker
 Debug Mode: false
 HTTP Proxy: http://proxy.***/
 HTTPS Proxy: http://proxy.***/
 Username: ***
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: true
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.) dockerd starts with:

/usr/bin/dockerd --config-file=/etc/docker/daemon.json --experimental -H tcp://*.*.*.*:2375 -H fd:// --containerd=/run/containerd/containerd.sock

daemon.json contains:

{ "features": { "buildkit": true } }

I also tried DOCKER_BUILDKIT=1 as an environment variable in systemd, didn't change anything.

Is it possible, that this feature will be implemented in the future but isn't because the python docker sdk doesn't support buildkit yet (https://github.com/docker/docker-py/issues/2230) ?

piwinkler avatar Oct 25 '20 20:10 piwinkler

I've also been having similar confusion using dockerode for Node.js.

Looking at the Docker API documentation BuildKit is only mentioned once in the outputs parameter description of the ImageBuild operation.

I've not been able to get BuildKit builds working over the Docker API so I would assume its not implemented yet, and only usable through the Docker CLI.

jshbrntt avatar Nov 24 '20 22:11 jshbrntt

This repo is deprecated and this issue has fixed in the correct repo: https://github.com/moby/moby/blob/master/api/swagger.yaml#L8722-L8731

While the default for the API is to use the first generation build version, setting version = "2" will use BuildKit

mikeseese avatar Jun 11 '24 02:06 mikeseese