0

when doing a docker compose up of a multi container app, I get an error about my volumes definition: services.volumes Additional property nginx is not allowed.

in my docker-compose.yaml, I defined the volumes as prescribed by docker: https://docs.docker.com/engine/context/aci-integration/#using-azure-file-share-as-volumes-in-aci-containers.

my docker-compose.yaml:

version: '3.4'
services:
  nginx:
    image: nginx
    container_name: nginx
    restart: always
    volumes:
      - nginxdata/conf.d:/etc/nginx/conf.d
      - nginx/basic_auth:/etc/nginx/basic_auth
    ports:
      - 80:80/tcp
      
volumes:
  nginxdata:
    driver: azure_file
    driver_opts:
      share_name: nginxdata
      storage_account_name: mystorageacct
  nginx:
    driver: azure_file
    driver_opts:
      share_name: nginx
      storage_account_name: mystorageacct

When I do a docker compose up, I get the error: "services.volumes Additional property nginxdata is not allowed".

Note: the azure shares exist and and for example, this works:

docker --context myaci run --name=nginxvolip -p 80:80 -v mystorageacct/nginx:/usr/share/nginx/html nginx

Did I miss something? Help is welcome!

hegenious
  • 3
  • 3

1 Answers1

0

Let's take a look at the example that works fine:

docker --context myaci run --name=nginxvolip -p 80:80 -v mystorageacct/nginx:/usr/share/nginx/html nginx

This command means you mount the File Share nginx in the storage mystorageacct to the path /usr/share/nginx/html and there is no problem. But in the docker-compose file, you configure the mount like this:

volumes:
      - nginxdata/conf.d:/etc/nginx/conf.d
      - nginx/basic_auth:/etc/nginx/basic_auth

It seems you want to mount the folder inside the File Share to the path inside the container. And that's the problem. You cannot mount the folders inside the File Share to the container, only the File Shares you can mount. And the error also shows the keywords that Additional property is not allowed. So the available mount should like this:

volumes:
      - nginxdata:/etc/nginx/conf.d
      - nginx:/etc/nginx/basic_auth
Charles Xu
  • 29,862
  • 2
  • 22
  • 39
  • Sorry for my late reply. You're right, only the File Shares can be mounted. The additional property error was related to wrong indentation in the yaml; the volumes definition should be on the same level as the services definition but it wasn't. After fixing both issues it works. Thank you Charles. – hegenious Dec 12 '20 at 07:52