How can I eliminate invalid volume specification error when using docker-compose to create a named volume for sql db in Windows Container?

I’m trying to use docker-compose to create a named volume for sql db in Windows container.

I keep getting the error:

"Severity Code Description Project File Line Suppression State Error Building webpresentation Recreating dockercompose6946136170613312467_webpresentation_1 … Creating dockercompose6946136170613312467_db_1 … Creating dockercompose6946136170613312467_db_1 … error ERROR: for dockercompose6946136170613312467_db_1 Cannot create container for service db: invalid volume specification: ‘dockercompose6946136170613312467_sqlvolume:/var/opt/mssql:rw’ Recreating dockercompose6946136170613312467_webpresentation_1 … done ERROR: for db Cannot create container for service db: invalid volume specification: ‘dockercompose6946136170613312467_sqlvolume:/var/opt/mssql:rw’ Encountered errors while bringing up the project…

For more troubleshooting information, go to http://aka.ms/DockerToolsTroubleshooting docker-compose C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets 363 "

Here is my docker-compose file:

    version: '3.4'

services:
  webpresentation:
    image: webpresentation
    build:
      context: .
      dockerfile: WebPresentation\Dockerfile

  db:
    image: microsoft/mssql-server-windows-express
    environment:
      ACCEPT_EULA: Y
      SA_PASSWORD: Test1
    ports:
      - "1433:1433"
    volumes:
      - sqlvolume:/var/opt/mssql

volumes:
  sqlvolume:

I should also mention that I’ve used Visual Studio’s Docker tools to set this project up here is the docker-compose.override.yml file as well:

version: '3.4'

services:
  webpresentation:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "80"
networks:
  default:
    external:
      name: nat

Can anyone point me in the right direction as to how to eliminate this error? Thanks!

If anyone else is having this problem, the project successfully built in Visual Studio after I did a docker volume ls and realized the actual volume name had an auto-generated “dockercompose” prefix. I then replaced every instance of “sqlvolume” with the new name. My complete docker-compose file is as follows:

version: '3.4'

services:
  webpresentation:
    image: webpresentation
    build:
      context: .
      dockerfile: WebPresentation\Dockerfile

  db:
    image: microsoft/mssql-server-windows-express
    environment:
      ACCEPT_EULA: Y
      SA_PASSWORD: Test1
    ports:
      - "1433:1433"
    volumes:
      - "C:\\ProgramData\\Docker\\volumes\\dockercompose6946136170613312467_sqlvolume:c:\\mssql"

volumes:
  dockercompose6946136170613312467_sqlvolume: