compose icon indicating copy to clipboard operation
compose copied to clipboard

[BUG] "bind source path does not exist" on v2.24.0

Open pjsmith404 opened this issue 1 year ago • 6 comments

Description

Hello,

On version 2.24.0 of docker compose, I get the following bind error when trying to run docker compose up, if the source directory does not already exist:

Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /tmp/logs

I expect that if the source directory does not exist, it should be automatically created. If I revert back to version 2.23.3, the error does not occur and the directory is created automatically as expected.

I didn't see anything in the change logs that indicated an expected change to this behaviour. Apologies if I overlooked something.

Cheers,

Pat

Steps To Reproduce

  1. Create a compose file located at /tmp/test.yml with the following content:
services:
  test:
    image: alpine
    volumes:
      - ./logs/:/tmp/logs/
    command: ls /tmp/logs/
  1. Run docker compose --file /tmp/test.yml up
  2. You should see the error Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /tmp/logs
  3. Create the folder /tmp/logs/
  4. Run docker compose --file /tmp/test.yml up.
  5. The container should launch as expected.

Compose Version

Docker Compose version v2.24.0

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.11.2)
  compose: Docker Compose (Docker Inc., v2.24.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.25
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 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.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 0cae528dd6cb557f7201036e9f43420650207b58
 runc version: f19387a6bec4944c770f7668ab51c4348d9c2f38
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.14.334-252.552.amzn2.x86_64
 Operating System: Amazon Linux 2
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 31.4GiB
 Name: ip-172-20-90-60.ap-southeast-2.compute.internal
 ID: ZHVR:BPLX:AZJW:A7YR:4F3Q:O77D:KZJ6:ZMFS:T4WU:6AXS:45ZS:QGMM
 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

pjsmith404 avatar Jan 15 '24 04:01 pjsmith404

We run into this problem as well. It is fine on 2.23.3

kinkerl avatar Jan 15 '24 10:01 kinkerl

Possible to update docker:latest image with this fix? It is quite blocking.

derlin avatar Jan 17 '24 09:01 derlin

@derlin a bug-fix release is planned later this week

ndeloof avatar Jan 17 '24 10:01 ndeloof

the bug is still exist on v2.29.7

snyh avatar Oct 12 '24 11:10 snyh

@snyh can't reproduce

>tmp docker compose -f test.yaml up
[+] Running 2/0
 ✔ Network tmp_default   Created                                           0.0s 
 ✔ Container tmp-test-1  Created                                           0.0s 
Attaching to test-1
test-1 exited with code 0

ndeloof avatar Oct 12 '24 12:10 ndeloof

Oh, I know the reason.

I used the long syntax of bind mount. In this case, the target will not be cleaned up.

[snyh@yoga-x1 cmd]$ cat bad.yml 
name: test_bind_long_syntax
services:
  test:
    image: alpine
    volumes:
      - type: bind
        source: /tmp/test-long_syntax_logs
        target: /tmp/logs/
        bind:
          create_host_path: true
[snyh@yoga-x1 cmd]$ ./cmd -f bad.yml create
[+] Creating 0/0
 ⠋ Container test_bind_long_syntax-test-1  Creating                                                                                                                      0.0s 
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /tmp/test-long_syntax_logs

snyh avatar Oct 13 '24 02:10 snyh