Skip to content

[BUG] Bind mounts for which source path does not exists fails on 2.35.0 #12735

@Kortekaasy

Description

@Kortekaasy

Description

We have a docker compose file with a bind mount of a file that might or might not exist, depending on if we want to host an extra site or not. This works fine when using Docker Compose v2.34.0 and lower. Starting Docker Compose version v2.35.0, this behavior results in an error of the form

⠋ Container webserver  Creating                                                                                             0.0s 
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /home/admin/webserver/my-extra-site.conf

Steps To Reproduce

Not reproducable on my Mac, but it is reproducable on a Debian AMI in AWS. Have not checked if this can be reproduced on a Debian VM.

  1. Take the latest Debian AMI on AWS (I took the arm64 variant)
  2. Update apt cache sudo apt-get update
  3. Install Docker sudo apt-get -y install docker.io
  4. Install docker-compose sudo curl -L https://github.com/docker/compose/releases/download/v2.35.0/docker-compose-Linux-aarch64 -o /usr/bin/docker-compose && sudo chmod +x /usr/bin/docker-compose
  5. Create a "webserver" directory mkdir webserver
  6. Add a docker-compose file docker-compose.yaml with contents
version: '2'
services:
  webserver:
    image: "nginx"
    container_name: webserver
    ports:
    - "8080:80"
    volumes:
    - ./my-extra-site.conf:/etc/nginx/sites-enabled/my-extra-site.conf
  1. Run docker-compose up in webserver directory, see the following error:
$ sudo docker-compose up 
WARN[0000] /home/admin/docker-compose.yaml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion 
[+] Running 8/8
 ✔ webserver Pulled                                                                                            5.6s 
   ✔ 16c9c4a8e9ee Pull complete                                                                                2.2s 
   ✔ 2e2bf7652052 Pull complete                                                                                3.5s 
   ✔ 38095d7651ea Pull complete                                                                                3.6s 
   ✔ 656814a9b758 Pull complete                                                                                3.7s 
   ✔ 81748182ebdb Pull complete                                                                                3.7s 
   ✔ c40fe051e83a Pull complete                                                                                3.8s 
   ✔ 73d1dc48607d Pull complete                                                                                3.9s 
[+] Running 1/2
 ✔ Network admin_default  Created                                                                              0.1s 
 ⠋ Container webserver    Creating                                                                             0.0s 
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /home/admin/webserver/my-extra-site.conf

Compose Version

$ docker compose version
docker: 'compose' is not a docker command.
See 'docker --help'
$ docker-compose version
Docker Compose version v2.35.0

Docker Environment

$ sudo docker info
Client:
 Context:    default
 Debug Mode: false

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 20.10.24+dfsg1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  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 logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1.6.20~ds1-1+deb12u1
 runc version: 1.1.5+ds1-1+deb12u1
 init version: 
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 6.1.0-32-cloud-arm64
 Operating System: Debian GNU/Linux 12 (bookworm)
 OSType: linux
 Architecture: aarch64
 CPUs: 2
 Total Memory: 7.649GiB
 Name: ip-10-38-5-54
 ID: XVBC:PLMG:5NEP:VNOA:QNLZ:FOYA:YHAN:NZTY:LCDR:S5PI:ZL2D:YPSI
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions