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

[bake] Cannot specify empty context for target #2611

Open
3 tasks done
brandond opened this issue Jul 17, 2024 · 0 comments · May be fixed by #2906
Open
3 tasks done

[bake] Cannot specify empty context for target #2611

brandond opened this issue Jul 17, 2024 · 0 comments · May be fixed by #2906

Comments

@brandond
Copy link

brandond commented Jul 17, 2024

Contributing guidelines

I've found a bug and checked that ...

  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

When using the legacy builder, you could read the Dockerfile from stdin to avoid sending any build context:
https://github.com/docker/cli/blob/24.0/docs/reference/commandline/build.md?plain=1#L267-L270

This will read a Dockerfile from STDIN without context. Due to the lack of a
context, no contents of any local directory will be sent to the Docker daemon.
Since there is no context, a Dockerfile ADD only works if it refers to a
remote URL.

There does not appear to be any similar way to request a null build context for a bake target. I am aware that other enhancements to the build system (ie only sending files from context when referenced by a COPY command) have made this largely unnecessary, but it would be nice to be able to explicitly request an empty/null context for the target.

Expected behaviour

Able to set a null context for the target.

Actual behaviour

cannot set an empty target. Null or empty string for the context are translated to the default ., and use of - is rejected with context from stdin not allowed in bake

Buildx version

github.com/docker/buildx v0.16.0 10c9ff9

Docker info

Client: Docker Engine - Community
 Version:    25.0.3
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.16.0
    Path:     /home/brandond/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.5
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 7
  Running: 7
  Paused: 0
  Stopped: 0
 Images: 20
 Server Version: 25.0.3
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.6.0-1001-aws
 Operating System: Ubuntu 24.04 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 30.57GiB
 Name: dev01.khaus.io
 ID: BMMG:V7I2:TKCO:ITI4:RQQE:W53K:3K25:KHWL:3TYH:RJ45:W6ZC:OPUS
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: brandond
 Experimental: false
 Insecure Registries:
  172.17.0.2:5000
  127.0.0.0/8
 Registry Mirrors:
  http://172.17.0.2:5000/
 Live Restore Enabled: false

Builders list

NAME/NODE      DRIVER/ENDPOINT                   STATUS    BUILDKIT   PLATFORMS
builder*       docker-container
 \_ builder0    \_ unix:///var/run/docker.sock   running   v0.15.0    linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/386
default        docker
 \_ default     \_ default                       running   v0.12.5    linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/386

Configuration

group "default" {
  targets = ["stage1", "stage2"]
}

target "stage1" {
  context = null
  dockerfile = "Dockerfile"
  output = ["type=cacheonly"]
}

target "stage2" {
  tags = ["example:latest"]
  output = ["type=docker"]
  dockerfile-inline = "FROM stage1\nCOPY . /source/"
  contexts = {
    "stage1" = "target:stage1"
  }
}

Build logs

No response

Additional info

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants