S S
S S

Reputation: 1503

How to set the docker volume in windows?

I have a folder test with a yaml file inside.

I have a following yaml file.

version: '3'
services:
  mariadb:
    image: 'bitnami/mariadb:10.3'
    volumes:
      - './test/docker_volumn/mariadb_data:/bitnami'
    environment:
      - MARIADB_USER=bn_wordpress
      - MARIADB_DATABASE=bitnami_wordpress
      - ALLOW_EMPTY_PASSWORD=yes
volumes:
  mariadb_data:
    driver: local
  wordpress_data:
    driver: local

When I try to run docker-compose up -d, it gives me error:

ERROR: for test_mariadb_1  Cannot create container for service mariadb: invalid volume specification: 'D:\test\docker_volumn\mariadb_data:/bitnami:rw': invalid mount config for type "bind": bind source path does not exist: d:\test\docker_volumn\mariadb_data

Does anyone knows how to fix this?

Upvotes: 0

Views: 511

Answers (1)

ckaserer
ckaserer

Reputation: 5702

Here are a few things to get you started:

You got a typo in your volume definition "volumn"

volumes:
  - './test/docker_volumn/mariadb_data:/bitnami'

Does the folder D:/test/docker_volumn/mariadb_data exist on your host? If not, create it beforehand (preferably without the typo ;) ).


Since you are writing a docker-compose file based on version: '3' I recommend to use the long syntax to define volumes as described in the docker-compose file reference to explicitly define the type of the volume in question.

volumes:
  - type: bind
    source: ./test/docker_volumn/mariadb_data
    target: /bitnami

Source

Upvotes: 1

Related Questions