compose: Short syntax for volumes is broken since update to 4.8.1

  • I have tried with the latest version of Docker Desktop
  • I have tried disabling enabled experimental features
  • I have uploaded Diagnostics
  • Diagnostics ID: C4B81C0F-902E-4779-9B40-C625F1F61C84/20220512124557

Actual behavior

After updating to Docker Desktop 4.8.1 “docker compose up” gives me three different Error responses:

  • Error response from daemon: create .docker/traefik/letsencrypt: “.docker/traefik/letsencrypt” includes invalid characters for a local volume name, only “[a-zA-Z0-9][a-zA-Z0-9_.-]” are allowed. If you intended to pass a host directory, use absolute path
  • Error response from daemon: create log/tmp: “log/tmp” includes invalid characters for a local volume name, only “[a-zA-Z0-9][a-zA-Z0-9_.-]” are allowed. If you intended to pass a host directory, use absolute path
  • Error response from daemon: create .: volume name is too short, names should be at least two alphanumeric characters

These errors don’t come all at once but rotate through for each time trying to mount the containers without changing anything to the Dockerfile or .env file

Expected behavior

“docker compose up” to work

Information

Issue is reproducible over multiple projects that ran just fine yesterday, before the update. The problem is new and only started occuring after the update to 4.8.1

  • Windows Version: Windows 10 Pro Version 21H2
  • Docker Desktop Version: 4.8.1 but also tried on 4.9.0 (79160) as per #12716
  • WSL2 or Hyper-V backend? Hyper-V
  • Are you running inside a virtualized Windows e.g. on a cloud server or a VM: No

Output of & "C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe" check

No fatal errors detected

Steps to reproduce the behavior

version: "3"

services:
  mssql:
    image: mcr.microsoft.com/mssql/server:2019-latest
    container_name: "${DOCKER_PROJECT_NAME}_mssql"
    user: root
    environment:
      ACCEPT_EULA: 'Y'
      MSSQL_SA_PASSWORD: $DATABASE_PASS
    ports:
      - "1433:1433"
    volumes:
      - mssql-volume:/var/opt/mssql/data

  mailhog:
    image: mailhog/mailhog
    container_name: "${DOCKER_PROJECT_NAME}_mailhog"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_mailhog.rule=Host(`mailhog.${DOCKER_PROJECT_URL}`)"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_mailhog.entrypoints=websecure"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_mailhog.tls.certresolver=myresolver"
      - "traefik.http.services.${DOCKER_PROJECT_NAME}_mailhog.loadbalancer.server.port=8025"

  nginx_backend:
    image: wodby/nginx:1.19
    container_name: "${DOCKER_PROJECT_NAME}_nginx_backend"
    depends_on:
      - php
    environment:
      NGINX_BACKEND_HOST: php
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_SERVER_ROOT: /var/www/html/web
      NGINX_STATIC_OPEN_FILE_CACHE: "off"
      NGINX_VHOST_PRESET: php
      NGINX_INDEX_FILE: admin_dev.php
      NGINX_FASTCGI_INDEX: admin_dev.php
      NGINX_SERVER_EXTRA_CONF_FILEPATH: /var/www/html/.docker/nginx/nginx-locations.conf
    env_file:
      - .env
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_nginx_backend.rule=Host(`${DOCKER_PROJECT_URL}`)"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_nginx_backend.entrypoints=websecure"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_nginx_backend.tls.certresolver=myresolver"
    volumes:
      - "./:/var/www/html"

  nginx_frontend:
    image: wodby/nginx:1.19
    container_name: "${DOCKER_PROJECT_NAME}_nginx_frontend"
    depends_on:
      - php
    environment:
      NGINX_BACKEND_HOST: php
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_SERVER_ROOT: /var/www/html/web
      NGINX_STATIC_OPEN_FILE_CACHE: "off"
      NGINX_VHOST_PRESET: php
      NGINX_INDEX_FILE: site_dev.php
      NGINX_FASTCGI_INDEX: site_dev.php
      NGINX_SERVER_EXTRA_CONF_FILEPATH: /var/www/html/.docker/nginx/nginx-locations.conf
    env_file:
      - .env
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_nginx_frontend.rule=Host(`${DOCKER_PROJECT_URL_FRONTEND}`)"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_nginx_frontend.entrypoints=websecure"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_nginx_frontend.tls.certresolver=myresolver"
    volumes:
      - "./:/var/www/html"

  composer:
    image: wodby/php:8.1-dev-macos-4.28.1
    container_name: "${DOCKER_PROJECT_NAME}_composer"
    environment:
      COLUMNS: 80
      PHP_SENDMAIL_PATH: "/usr/sbin/sendmail -t -i -S mailhog:1025"
    env_file:
      - .env
    volumes:
      - "./:/var/www/html"

  php:
    image: wodby/php:8.1-dev-macos-4.28.1
    container_name: "${DOCKER_PROJECT_NAME}_php"
    environment:
      COLUMNS: 80
      PHP_SENDMAIL_PATH: "/usr/sbin/sendmail -t -i -S mailhog:1025"
      DB_HOST: $DATABASE_HOST
      DB_USER: $DATABASE_USER
      DB_PASSWORD: $DATABASE_PASS
      DB_NAME: $DATABASE_NAME
      DB_DRIVER: $DATABASE_DRIVER
      PHP_DEFAULT_CHARSET: 'utf-8'
      PHP_DATE_TIMEZONE: 'UTC'
      PHP_UPLOAD_MAX_FILESIZE: '10M'
      PHP_POST_MAX_SIZE: '10M'
      PHP_DISPLAY_ERRORS: 'On'
      PHP_DISPLAY_STARTUP_ERRORS: 'On'
      PHP_MAX_EXECUTION_TIME: '30000'
      PHP_MAX_INPUT_TIME: '60'
      PHP_MAX_INPUT_VARS: '2000'
      PHP_ERROR_REPORTING: 'E_ALL'
      PHP_LOG_ERRORS: 'On'
      PHP_LOG_ERRORS_MAX_LEN: '0'
      PHP_MEMORY_LIMIT: '512M'
      PHP_SESSION_GC_MAXLIFETIME: '700000'
      PHP_REALPATH_CACHE_SIZE: '4096K'
      PHP_REALPATH_CACHE_TTL: '3600'
      PHP_XHPROF: $PROFILING_ENABLED
      PHP_SESSION_SAVE_PATH: '/tmp'
    env_file:
      - .env
    volumes:
      - "./:/var/www/html"
      - "./log/php:/var/log"
      - "./log/tmp:/tmp"
      - "./.docker/php/conf.d/docker-php-extra.ini:/usr/local/etc/php/conf.d/docker-php-extra.ini"
      ## For php profiler traces
      - "files:/mnt/files"

  xhprof:
    image: wodby/xhprof:2.7.1
    container_name: "${DOCKER_PROJECT_NAME}_xhprof"
    restart: always
    volumes:
      - files:/mnt/files
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_xhprof.rule=Host(`xhprof.${DOCKER_PROJECT_URL}`)"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_xhprof.entrypoints=websecure"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_xhprof.tls.certresolver=myresolver"

  crond:
    image: wodby/php:8.1-dev-macos-4.28.1
    container_name: "${DOCKER_PROJECT_NAME}_crond"
    command: "sudo -E LD_PRELOAD=/usr/lib/preloadable_libiconv.so crond -f -d 0"
    volumes:
      - "./:/var/www/html"
      - "./.docker/crond/crontab/:/etc/crontabs/www-data"

  redis:
    image: wodby/redis:4-3.2.2
    container_name: "${DOCKER_PROJECT_NAME}_redis"

  portainer:
    image: portainer/portainer
    container_name: "${DOCKER_PROJECT_NAME}_portainer"
    command: "--no-auth -H unix:///var/run/docker.sock"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_portainer.rule=Host(`portainer.${DOCKER_PROJECT_URL}`)"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_portainer.entrypoints=websecure"
      - "traefik.http.routers.${DOCKER_PROJECT_NAME}_portainer.tls.certresolver=myresolver"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"

  traefik:
    image: traefik:v2.0
    container_name: "${DOCKER_PROJECT_NAME}_traefik"
    command:
      - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      # Traefik will listen to incoming request on the port 443 (https) and 80 (http)
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      # Enable a http challenge named myresolver"
      - "--certificatesresolvers.myresolver.acme.httpchallenge=true"
      # Tell it to use our predefined entrypoint named "web"
      - "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
      # Tell to store the certificate on a path under our volume
      - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
      # The email to provide to let's encrypt
      - "--certificatesresolvers.myresolver.acme.email=info@tactics.be"
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - "./.docker/traefik/letsencrypt:/letsencrypt"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

volumes:
  ## For database
  mssql-volume:
  ## For php profiler
  files:

.env:

###> Docker ###
DOCKER_PROJECT_URL=project.test
DOCKER_PROJECT_URL8=project8.test
DOCKER_PROJECT_URL_FRONTEND=project.site
DOCKER_PROJECT_URL_FRONTEND8=
DOCKER_PROJECT_NAME=project
###< End Docker ###

###> Profiling  ###
PROFILING_ENABLED=false
###> End profiling ###

###> Database  ###
DATABASE_ADAPTER=sqlsrv
DATABASE_DRIVER=mssql
DATABASE_HOST=project_mssql
DATABASE_NAME=db
DATABASE_USER=sa
DATABASE_PASS=pass
DATABASE_PORT=1433
DATABASE_CHARSET=utf8
DATABASE_URL=mssql://${DATABASE_USER}:${DATABASE_PASS}@${DATABASE_HOST}/${DATABASE_NAME}
###> End Database ###
  1. Start a project with the Dockerfile and .env listed above
  2. run the “docker compose run” commando in the command line
  3. Error…

EDIT: The bug was introduced in version 4.8.0. Short syntax still works in version 4.7.1 As per this comment it probably has something to do with the short syntax used in the volume config. Using Long syntax still works on version 4.8.1 (and on version 4.7.1)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 26 (5 by maintainers)

Most upvoted comments

Same issue for me. However disabling this fixed it for me:

image

Fix by #9475

I have the same issue:

  • Error response from daemon: create mongoService/mongoData: “mongoService/mongoData” includes invalid characters for a local volume name, only “[a-zA-Z0-9][a-zA-Z0-9_.-]” are allowed. If you intended to pass a host directory, use absolute path.

Docker compose worked previously to upgrade.

for what it’s worth, i had success in my own environment (running Docker 4.8.1) by changing my volume config to the docker-compose long syntax for volumes.

i.e. changing this

        volumes:
          - ./src/config:/app/config
          - ./src/templates:/app/templates

to

        volumes:
          - type: bind
            source: src/config
            target: /app/config
          - type: bind
            source: src/templates
            target: /app/templates

seems possible that something’s changed or inadvertently broke in the parsing for short syntax.

For all of you, is it resolved if you revert to 4.7.1?

I just tried and can confirm that it is working as expected on version 4.7.1 and stopped working on 4.8.0 I will be testing out @mtigas his suggestion on 4.8.1 later today

Confirming this works for me starting with Docker Desktop for Windows 4.8.2, using docker-compose v2.5.1. 🚀

@patricknelson

The following (my original code) results in the error
Error response from daemon: create ./src/config: "./src/config" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path

        volumes:
          - ./src/config:/app/config
          - ./src/templates:/app/templates

The following (your suggestion) results in the same error
Error response from daemon: create ./src/config: "./src/config" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path

        volumes:
          - "./src/config:/app/config"
          - "./src/templates:/app/templates"

The following works fine

        volumes:
          - type: bind
            source: src/config
            target: /app/config
          - type: bind
            source: src/templates
            target: /app/templates

And in fact, this does as well:

        volumes:
          - type: bind
            source: ./src/config
            target: /app/config
          - type: bind
            source: ./src/templates
            target: /app/templates

Note that the above testing is on a Mac, not Docker For Windows, which I realize is what repo this issue is on. This is probably actually a bug in Docker or Docker Compose more generally.

And I do have “Use Docker Compose V2” enabled, as well.

$ docker version
Client:
 Cloud integration: v1.0.24
 Version:           20.10.14
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        a224086
 Built:             Thu Mar 24 01:49:20 2022
 OS/Arch:           darwin/arm64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.8.1 (78998)
 Engine:
  Version:          20.10.14
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       87a90dc
  Built:            Thu Mar 24 01:45:44 2022
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.5.11
  GitCommit:        3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc:
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

$ docker-compose version
Docker Compose version v2.5.0

$ docker compose version
Docker Compose version v2.5.0