Skip to content

The --project-directory option not working anymore #9373

@nekofar

Description

@nekofar

Description

I've updated the docker couple of days ago to v2.4.1 and since then, I've problems with relative paths on compose.yml. I've already used --project-directory for addressing the working directory, and it works fine, but it's not working anymore, at least with the current docker compose. It works fine with docker-compose-v1.

Steps to reproduce the issue:

docker compose -f ./.docker/compose.yml --project-directory ./.docker up --detach --remove-orphans

Describe the results you received:

[+] Running 1/2
 ⠿ Network simple-project_default    Created                                                                                                                                   0.2s
 ⠋ Container simple-project-mysql-1  Creating                                                                                                                                  0.1s
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /path/to/simple-project/mysql/docker-entrypoint-initdb.d

Describe the results you expected:

docker-compose-v1 -f ./.docker/compose.yml --project-directory ./.docker up --detach --remove-orphans
Creating simple-project_mysql_1 ... done
Creating simple-project_php_1   ... done

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker compose version:

Docker Compose version v2.4.1

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.8.2)
  compose: Docker Compose (Docker Inc., v2.4.1)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 4
  Running: 2
  Paused: 0
  Stopped: 2
 Images: 28
 Server Version: 20.10.14
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 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.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc version: v1.0.3-0-gf46b6ba
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.10.104-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.843GiB
 Name: docker-desktop
 ID: 3DHJ:YFRA:HU4C:WW77:7GRJ:CGQY:O2LE:MJWE:MPTS:WQOS:RG7N:2K43
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details:

Content of simple-project directory:

.
├── .docker
│  ├── .env
│  ├── compose.yml
│  ├── mysql
│  │  ├── docker-entrypoint-initdb.d
│  │  └── Dockerfile
│  └── php
│     ├── conf.d
│     └── Dockerfile
├── logs
│  ├── .gitignore
│  └── .htaccess
└── README.md

Content of .docker/compose.yml:

version: "3.9"

services:
  php:
    build:
      context: ./php
    ports:
      - target: 80
        published: 8081
        protocol: tcp
        mode: host
    links:
      - mysql
    depends_on:
      - mysql
    volumes:
      - type: bind
        source: ../
        target: /var/www/html
      - type: bind
        source: ../logs
        target: /var/www/logs
      - type: bind
        source: ./php/conf.d/php.ini
        target: /usr/local/etc/php/conf.d/custom.ini
        read_only: true
    environment:
      WAIT_HOSTS: mysql:3306
      WAIT_TIMEOUT: 300
      WAIT_SLEEP_INTERVAL: 30
      WAIT_HOST_CONNECT_TIMEOUT: 30
      WAIT_LOGGER_LEVEL: info
  mysql:
    build:
      context: ./mysql
    ports:
      - target: 3306
        published: 3307
        protocol: tcp
        mode: host
    volumes:
      - type: bind
        source: ./mysql/docker-entrypoint-initdb.d
        target: /docker-entrypoint-initdb.d
        read_only: true
    environment:
      MYSQL_DATABASE: ${DATABASE_NAME}
      MYSQL_ROOT_PASSWORD: ${DATABASE_PASS}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions