Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker-compose toolbox secrets files not mounting properly

I am trying to compose a stack using secrets for development, i use local files in docker/secrets/FILE_NAME I had this working in windows 10, but I'm struggling to get it to work under win7 toolbox. I get an error:

Cannot create container for service db: 
invalid volume specification:
 'C:\project\docker\secrets\DB_USERNAME:/run/secrets/db-username:ro'

I was trying to set COMPOSE_CONVERT_WINDOWS_PATH but unfortunately, this does not change anything. I will get the same output with true or false. Setting absolute paths did not help either.

Docker compose version 1.16.1 build 6d1ac219 Docker version 17.10.0-ce, build f4ffd25

My docker-compose.yml

version: '3.3'

services:
  db:
    image: postgres
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
      - POSTGRES_USER_FILE=/run/secrets/db-username
      - POSTGRES_DB_FILE=/run/secrets/db-name
    secrets:
      - db-username
      - db-password
      - db-name
  web:
    build: 
      context: ./docker/machines/django/
      args:
        buildno: 1
    command: python3 manage.py runserver 0.0.0.0:8000
    volumes:
      - ./Server:/Server
    ports:
      - "8000:8000"
    depends_on:
      - db
    secrets:
      - db-username
      - db-password
      - db-name

secrets:
  db-username:
    file: ./docker/secrets/DB_USERNAME
  db-password:
    file: ./docker/secrets/DB_PASSWORD
  db-name:
    file: ./docker/secrets/DB_NAME

volumes:
  db-data:
    driver: "local"
like image 641
farghost Avatar asked Dec 10 '25 02:12

farghost


1 Answers

it is likely to due to difference in how Windows 7 and Windows 10 handle file paths. Docker Toolbox, which is used for older Windows systems that do not support Docker Desktop (like Windows 7), runs in a VirtualBox VM and has different path requirements.

In Docker Toolbox, project should be located in the C:\Users directory. This is because Docker Toolbox can only mount file paths from the C:\Users directory. So, if your project is located outside of this directory, Docker Toolbox won’t be able to find the files.

you can move your project to C:\Users and update the paths in docker-compose.yml file to reflect the new location.

For example, if your username is myuser and you moved your project to a folder named myproject in the C:\Users directory, the paths would look like this:

secrets:
  db-username:
    file: /c/Users/myuser/myproject/docker/secrets/DB_USERNAME
  db-password:
    file: /c/Users/myuser/myproject/docker/secrets/DB_PASSWORD
  db-name:
    file: /c/Users/myuser/myproject/docker/secrets/DB_NAME
like image 95
amin Avatar answered Dec 14 '25 04:12

amin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!