Skip to content

[BUG] The new service: directive does not work with docker compose run --build #13159

@peterfajdiga

Description

@peterfajdiga

Description

Likely a regression of #12822

Running docker compose run --build b where b has an additional context in the form of "service:a" returns this error:

[+] Building 0.0s (1/1) FINISHED                                                                           
 => [internal] load local bake definitions                                                            0.0s
 => => reading from stdin 665B                                                                        0.0s
failed to find target

docker compose up --build works fine.

Steps To Reproduce

  1. Define the following services (copied from [BUG] The new service: directive does not work with docker compose up --build #12822):
      a:
        image: service_a
        build: 
          dockerfile_inline: "FROM alpine"
      b:
         image: service_b
         build:
           args:
             BASE_IMAGE: service_a
           dockerfile_inline: "FROM service_a"
           additional_contexts:
             # instructs resolving `FROM service_a` to "service a" image
             service_a: "service:a"
    
  2. Run docker compose run --build b
  3. See error
    [+] Building 0.0s (1/1) FINISHED                                                                           
     => [internal] load local bake definitions                                                            0.0s
     => => reading from stdin 665B                                                                        0.0s
    failed to find target
    

Compose Version

Docker Compose version 2.39.2.

Docker Environment

Client:
 Version:    28.3.3-ce
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  0.26.1
    Path:     /usr/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.39.2
    Path:     /usr/lib/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 47
 Server Version: 28.3.3-ce
 Storage Driver: overlay2
  Backing Filesystem: btrfs
  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
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: oci runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05044ec0a9a75232cad458027ca83437aae3f4da
 runc version: v1.3.0-0-g4ca628d1d4c9
 init version: 
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.16.1-1-default
 Operating System: openSUSE Tumbleweed
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 15.33GiB
 Name: localhost.localdomain
 ID: d45b55d2-9d16-4fad-a7db-dfc54310dd48
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions