0
votes

for our product we have a folder with configuration files which are different for each of our customers. therefore this files are outside of the build context.

i have tried to add a volume to the docker-compose file. you can see the file below, which causes following error

  • ERROR: for my_product Cannot create container for service my_product: invalid volume specification: 'C:\path\to\container\conf:/var/my_config:rw'

and than i want to copy the content of the config folder to the docker container (in the dockerfile)

docker-compose file:

version: '3.4'

services:
     my_product:
     image: ${DOCKER_REGISTRY}my_product
     volumes:
      - .\container\conf:/var/my_config:rw
     build:
        context: .\container\Web
        dockerfile: Dockerfile

Dockerfile:

 FROM microsoft/aspnet:4.7.2-windowsservercore-1803
 ARG source
 WORKDIR /inetpub/wwwroot
 COPY ${source:-obj/Docker/publish} .
 COPY /var/my_config/. /inetpub/wwwroot/@conf/.

I am not able to fix the error in the docker-compose file and I am not sure if it is possible or a good idea to copy the my_conf folder in the dockerfile.

regards, Marko

Updated docker-compose.yml

version: '3.4'

services:
  my_product:
    image: ${DOCKER_REGISTRY}my_product
    environment:
      COMPOSE_CONVERT_WINDOWS_PATHS: "0"
    volumes:
      - .\container\conf:/var/my_config:rw
    build:
      context: .\container\Web
      dockerfile: Dockerfile

i still get the 'invalid volume specification' error.

1

1 Answers

0
votes

I don't think it's a problem with your docker-compose file. Try setting COMPOSE_CONVERT_WINDOWS_PATHS=0 in the windows shell.

Also try Settings - Shared Drives if your local drive is shared.

Last but not least you might try to create the volume separetely in the docker compose file and then add it to the container.

services:
  my product:
     build:
        context: .\container\Web
        dockerfile: Dockerfile
      volumes:
        newvolume:C:\path:/var/path/conf:rw

volumes:
      newvolume: