dotnet watch run in container with multi-project solution











up vote
0
down vote

favorite












I'm trying to create a Dockerfile along with a docker-compose.yml file to run dotnet watch run on a multi project ASP.Net Core solution. The goal is to have a container watching for changes in all of the three projects.



My solution structure is this:



Nc.Application
Nc.Domain
Nc.Infrastructure
docker-compose.yml


Nc.Application contains the main project to run, and the other two folders are .Net standard projects referenced by the main project. Inside Nc.Application i have a folder, Docker, with my dockerfile.



Controllers
Docker
Development.Dockerfile
Properties
Program.cs
Startup.cs
...


My Dockerfile and compose file contains the following:



Development.Dockerfile



FROM microsoft/dotnet:2.1-sdk AS build
ENTRYPOINT [ "dotnet", "watch", "run", "--no-restore", "--urls", "http://0.0.0.0:5000" ]


docker-compose.yml



version: '3'

services:

nc.api:
container_name: ncapi_dev
image: ncapi:dev
build:
context: ./Nc.Application
dockerfile: Docker/Development.Dockerfile
volumes:
- ncapi.volume:.
ports:
- "5000:5000"
- "5001:5001"

volumes:
ncapi.volume:


When i try to run docker-compose up i get the following error:



ERROR: for f6d811109779_ncapi_dev  Cannot create container for service nc.api: invalid volume specification: 'nc_ncapi.volume:.:rw': invalid mount config for type "volume": invalid mount path: '.' mount path
must be absolute

ERROR: for nc.api Cannot create container for service nc.api: invalid volume specification: 'nc_ncapi.volume:.:rw': invalid mount config for type "volume": invalid mount path: '.' mount path must be absolute
ERROR: Encountered errors while bringing up the project.


I don't know what the path for the volume should be, as the idea is to create
a container not directly containing files, but watching files in a folder on my system.



Does anyone have any suggestions as to how to go about this?



EDIT:



I updated WORKDIR in Dockerfile to /app/Nc.Application, updated the volume path to be ./:/app and removed the named volume volumes: ncapi.volume. However, i now receive the following error:



ncapi_dev | watch : Polling file watcher is enabled
ncapi_dev | watch : Started
ncapi_dev | /usr/share/dotnet/sdk/2.1.403/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(198,5): error NETSDK1004: Assets file '/app/Nc.Application/c:/Users/Christian/Documents/source/nc/Nc.Application/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/app/Nc.Application/Nc.Application.csproj]
ncapi_dev |
ncapi_dev | The build failed. Please fix the build errors and run again.
ncapi_dev | watch : Exited with error code 1
ncapi_dev | watch : Waiting for a file to change before restarting dotnet...









share|improve this question




























    up vote
    0
    down vote

    favorite












    I'm trying to create a Dockerfile along with a docker-compose.yml file to run dotnet watch run on a multi project ASP.Net Core solution. The goal is to have a container watching for changes in all of the three projects.



    My solution structure is this:



    Nc.Application
    Nc.Domain
    Nc.Infrastructure
    docker-compose.yml


    Nc.Application contains the main project to run, and the other two folders are .Net standard projects referenced by the main project. Inside Nc.Application i have a folder, Docker, with my dockerfile.



    Controllers
    Docker
    Development.Dockerfile
    Properties
    Program.cs
    Startup.cs
    ...


    My Dockerfile and compose file contains the following:



    Development.Dockerfile



    FROM microsoft/dotnet:2.1-sdk AS build
    ENTRYPOINT [ "dotnet", "watch", "run", "--no-restore", "--urls", "http://0.0.0.0:5000" ]


    docker-compose.yml



    version: '3'

    services:

    nc.api:
    container_name: ncapi_dev
    image: ncapi:dev
    build:
    context: ./Nc.Application
    dockerfile: Docker/Development.Dockerfile
    volumes:
    - ncapi.volume:.
    ports:
    - "5000:5000"
    - "5001:5001"

    volumes:
    ncapi.volume:


    When i try to run docker-compose up i get the following error:



    ERROR: for f6d811109779_ncapi_dev  Cannot create container for service nc.api: invalid volume specification: 'nc_ncapi.volume:.:rw': invalid mount config for type "volume": invalid mount path: '.' mount path
    must be absolute

    ERROR: for nc.api Cannot create container for service nc.api: invalid volume specification: 'nc_ncapi.volume:.:rw': invalid mount config for type "volume": invalid mount path: '.' mount path must be absolute
    ERROR: Encountered errors while bringing up the project.


    I don't know what the path for the volume should be, as the idea is to create
    a container not directly containing files, but watching files in a folder on my system.



    Does anyone have any suggestions as to how to go about this?



    EDIT:



    I updated WORKDIR in Dockerfile to /app/Nc.Application, updated the volume path to be ./:/app and removed the named volume volumes: ncapi.volume. However, i now receive the following error:



    ncapi_dev | watch : Polling file watcher is enabled
    ncapi_dev | watch : Started
    ncapi_dev | /usr/share/dotnet/sdk/2.1.403/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(198,5): error NETSDK1004: Assets file '/app/Nc.Application/c:/Users/Christian/Documents/source/nc/Nc.Application/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/app/Nc.Application/Nc.Application.csproj]
    ncapi_dev |
    ncapi_dev | The build failed. Please fix the build errors and run again.
    ncapi_dev | watch : Exited with error code 1
    ncapi_dev | watch : Waiting for a file to change before restarting dotnet...









    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm trying to create a Dockerfile along with a docker-compose.yml file to run dotnet watch run on a multi project ASP.Net Core solution. The goal is to have a container watching for changes in all of the three projects.



      My solution structure is this:



      Nc.Application
      Nc.Domain
      Nc.Infrastructure
      docker-compose.yml


      Nc.Application contains the main project to run, and the other two folders are .Net standard projects referenced by the main project. Inside Nc.Application i have a folder, Docker, with my dockerfile.



      Controllers
      Docker
      Development.Dockerfile
      Properties
      Program.cs
      Startup.cs
      ...


      My Dockerfile and compose file contains the following:



      Development.Dockerfile



      FROM microsoft/dotnet:2.1-sdk AS build
      ENTRYPOINT [ "dotnet", "watch", "run", "--no-restore", "--urls", "http://0.0.0.0:5000" ]


      docker-compose.yml



      version: '3'

      services:

      nc.api:
      container_name: ncapi_dev
      image: ncapi:dev
      build:
      context: ./Nc.Application
      dockerfile: Docker/Development.Dockerfile
      volumes:
      - ncapi.volume:.
      ports:
      - "5000:5000"
      - "5001:5001"

      volumes:
      ncapi.volume:


      When i try to run docker-compose up i get the following error:



      ERROR: for f6d811109779_ncapi_dev  Cannot create container for service nc.api: invalid volume specification: 'nc_ncapi.volume:.:rw': invalid mount config for type "volume": invalid mount path: '.' mount path
      must be absolute

      ERROR: for nc.api Cannot create container for service nc.api: invalid volume specification: 'nc_ncapi.volume:.:rw': invalid mount config for type "volume": invalid mount path: '.' mount path must be absolute
      ERROR: Encountered errors while bringing up the project.


      I don't know what the path for the volume should be, as the idea is to create
      a container not directly containing files, but watching files in a folder on my system.



      Does anyone have any suggestions as to how to go about this?



      EDIT:



      I updated WORKDIR in Dockerfile to /app/Nc.Application, updated the volume path to be ./:/app and removed the named volume volumes: ncapi.volume. However, i now receive the following error:



      ncapi_dev | watch : Polling file watcher is enabled
      ncapi_dev | watch : Started
      ncapi_dev | /usr/share/dotnet/sdk/2.1.403/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(198,5): error NETSDK1004: Assets file '/app/Nc.Application/c:/Users/Christian/Documents/source/nc/Nc.Application/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/app/Nc.Application/Nc.Application.csproj]
      ncapi_dev |
      ncapi_dev | The build failed. Please fix the build errors and run again.
      ncapi_dev | watch : Exited with error code 1
      ncapi_dev | watch : Waiting for a file to change before restarting dotnet...









      share|improve this question















      I'm trying to create a Dockerfile along with a docker-compose.yml file to run dotnet watch run on a multi project ASP.Net Core solution. The goal is to have a container watching for changes in all of the three projects.



      My solution structure is this:



      Nc.Application
      Nc.Domain
      Nc.Infrastructure
      docker-compose.yml


      Nc.Application contains the main project to run, and the other two folders are .Net standard projects referenced by the main project. Inside Nc.Application i have a folder, Docker, with my dockerfile.



      Controllers
      Docker
      Development.Dockerfile
      Properties
      Program.cs
      Startup.cs
      ...


      My Dockerfile and compose file contains the following:



      Development.Dockerfile



      FROM microsoft/dotnet:2.1-sdk AS build
      ENTRYPOINT [ "dotnet", "watch", "run", "--no-restore", "--urls", "http://0.0.0.0:5000" ]


      docker-compose.yml



      version: '3'

      services:

      nc.api:
      container_name: ncapi_dev
      image: ncapi:dev
      build:
      context: ./Nc.Application
      dockerfile: Docker/Development.Dockerfile
      volumes:
      - ncapi.volume:.
      ports:
      - "5000:5000"
      - "5001:5001"

      volumes:
      ncapi.volume:


      When i try to run docker-compose up i get the following error:



      ERROR: for f6d811109779_ncapi_dev  Cannot create container for service nc.api: invalid volume specification: 'nc_ncapi.volume:.:rw': invalid mount config for type "volume": invalid mount path: '.' mount path
      must be absolute

      ERROR: for nc.api Cannot create container for service nc.api: invalid volume specification: 'nc_ncapi.volume:.:rw': invalid mount config for type "volume": invalid mount path: '.' mount path must be absolute
      ERROR: Encountered errors while bringing up the project.


      I don't know what the path for the volume should be, as the idea is to create
      a container not directly containing files, but watching files in a folder on my system.



      Does anyone have any suggestions as to how to go about this?



      EDIT:



      I updated WORKDIR in Dockerfile to /app/Nc.Application, updated the volume path to be ./:/app and removed the named volume volumes: ncapi.volume. However, i now receive the following error:



      ncapi_dev | watch : Polling file watcher is enabled
      ncapi_dev | watch : Started
      ncapi_dev | /usr/share/dotnet/sdk/2.1.403/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(198,5): error NETSDK1004: Assets file '/app/Nc.Application/c:/Users/Christian/Documents/source/nc/Nc.Application/obj/project.assets.json' not found. Run a NuGet package restore to generate this file. [/app/Nc.Application/Nc.Application.csproj]
      ncapi_dev |
      ncapi_dev | The build failed. Please fix the build errors and run again.
      ncapi_dev | watch : Exited with error code 1
      ncapi_dev | watch : Waiting for a file to change before restarting dotnet...






      docker docker-compose






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 at 18:05

























      asked Nov 10 at 12:21









      Mike Hawkins

      8911




      8911
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          You shouldn't mount things at the root of the container. Use another mount point like /app. Also, you don't need a named volume but a bind mount for this situation.



          Make changes like this



          Development.Dockerfile



          FROM microsoft/dotnet:2.1-sdk AS build
          WORKDIR /app
          ENTRYPOINT [ "dotnet", "watch", "run", "--no-restore", "--urls", "http://0.0.0.0:5000" ]


          docker-compose.yml



          version: '3'

          services:

          nc.api:
          container_name: ncapi_dev
          image: ncapi:dev
          build:
          context: ./Nc.Application
          dockerfile: Docker/Development.Dockerfile
          volumes:
          - ./:/app
          ports:
          - "5000:5000"
          - "5001:5001"





          share|improve this answer





















          • Thank you for your reply, i have updated my original question. I now receive a new error
            – Mike Hawkins
            Nov 14 at 9:22










          • It's because you are using an absolute path to that asset. You will have to change it to a relative one since from inside the container, you can't access the windows drives directly.
            – Pramodh Valavala
            Nov 14 at 17:27










          • I dont understand. What change to the WORKDIR do i need to make then?
            – Mike Hawkins
            Nov 14 at 18:04










          • The error is because the path where it's searching for project.assets.json is wrong. Try removing the bin and obj folders and also the --no-restore flag from your dockerfile.
            – Pramodh Valavala
            Nov 14 at 18:15










          • I tried it, however, VS Code prompts me to restore packages everytime i have made a change to the code, detected by the watcher. I would like to not have it need to restore packages upon every code change.
            – Mike Hawkins
            Nov 14 at 18:19













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238901%2fdotnet-watch-run-in-container-with-multi-project-solution%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          You shouldn't mount things at the root of the container. Use another mount point like /app. Also, you don't need a named volume but a bind mount for this situation.



          Make changes like this



          Development.Dockerfile



          FROM microsoft/dotnet:2.1-sdk AS build
          WORKDIR /app
          ENTRYPOINT [ "dotnet", "watch", "run", "--no-restore", "--urls", "http://0.0.0.0:5000" ]


          docker-compose.yml



          version: '3'

          services:

          nc.api:
          container_name: ncapi_dev
          image: ncapi:dev
          build:
          context: ./Nc.Application
          dockerfile: Docker/Development.Dockerfile
          volumes:
          - ./:/app
          ports:
          - "5000:5000"
          - "5001:5001"





          share|improve this answer





















          • Thank you for your reply, i have updated my original question. I now receive a new error
            – Mike Hawkins
            Nov 14 at 9:22










          • It's because you are using an absolute path to that asset. You will have to change it to a relative one since from inside the container, you can't access the windows drives directly.
            – Pramodh Valavala
            Nov 14 at 17:27










          • I dont understand. What change to the WORKDIR do i need to make then?
            – Mike Hawkins
            Nov 14 at 18:04










          • The error is because the path where it's searching for project.assets.json is wrong. Try removing the bin and obj folders and also the --no-restore flag from your dockerfile.
            – Pramodh Valavala
            Nov 14 at 18:15










          • I tried it, however, VS Code prompts me to restore packages everytime i have made a change to the code, detected by the watcher. I would like to not have it need to restore packages upon every code change.
            – Mike Hawkins
            Nov 14 at 18:19

















          up vote
          0
          down vote













          You shouldn't mount things at the root of the container. Use another mount point like /app. Also, you don't need a named volume but a bind mount for this situation.



          Make changes like this



          Development.Dockerfile



          FROM microsoft/dotnet:2.1-sdk AS build
          WORKDIR /app
          ENTRYPOINT [ "dotnet", "watch", "run", "--no-restore", "--urls", "http://0.0.0.0:5000" ]


          docker-compose.yml



          version: '3'

          services:

          nc.api:
          container_name: ncapi_dev
          image: ncapi:dev
          build:
          context: ./Nc.Application
          dockerfile: Docker/Development.Dockerfile
          volumes:
          - ./:/app
          ports:
          - "5000:5000"
          - "5001:5001"





          share|improve this answer





















          • Thank you for your reply, i have updated my original question. I now receive a new error
            – Mike Hawkins
            Nov 14 at 9:22










          • It's because you are using an absolute path to that asset. You will have to change it to a relative one since from inside the container, you can't access the windows drives directly.
            – Pramodh Valavala
            Nov 14 at 17:27










          • I dont understand. What change to the WORKDIR do i need to make then?
            – Mike Hawkins
            Nov 14 at 18:04










          • The error is because the path where it's searching for project.assets.json is wrong. Try removing the bin and obj folders and also the --no-restore flag from your dockerfile.
            – Pramodh Valavala
            Nov 14 at 18:15










          • I tried it, however, VS Code prompts me to restore packages everytime i have made a change to the code, detected by the watcher. I would like to not have it need to restore packages upon every code change.
            – Mike Hawkins
            Nov 14 at 18:19















          up vote
          0
          down vote










          up vote
          0
          down vote









          You shouldn't mount things at the root of the container. Use another mount point like /app. Also, you don't need a named volume but a bind mount for this situation.



          Make changes like this



          Development.Dockerfile



          FROM microsoft/dotnet:2.1-sdk AS build
          WORKDIR /app
          ENTRYPOINT [ "dotnet", "watch", "run", "--no-restore", "--urls", "http://0.0.0.0:5000" ]


          docker-compose.yml



          version: '3'

          services:

          nc.api:
          container_name: ncapi_dev
          image: ncapi:dev
          build:
          context: ./Nc.Application
          dockerfile: Docker/Development.Dockerfile
          volumes:
          - ./:/app
          ports:
          - "5000:5000"
          - "5001:5001"





          share|improve this answer












          You shouldn't mount things at the root of the container. Use another mount point like /app. Also, you don't need a named volume but a bind mount for this situation.



          Make changes like this



          Development.Dockerfile



          FROM microsoft/dotnet:2.1-sdk AS build
          WORKDIR /app
          ENTRYPOINT [ "dotnet", "watch", "run", "--no-restore", "--urls", "http://0.0.0.0:5000" ]


          docker-compose.yml



          version: '3'

          services:

          nc.api:
          container_name: ncapi_dev
          image: ncapi:dev
          build:
          context: ./Nc.Application
          dockerfile: Docker/Development.Dockerfile
          volumes:
          - ./:/app
          ports:
          - "5000:5000"
          - "5001:5001"






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 at 5:55









          Pramodh Valavala

          45627




          45627












          • Thank you for your reply, i have updated my original question. I now receive a new error
            – Mike Hawkins
            Nov 14 at 9:22










          • It's because you are using an absolute path to that asset. You will have to change it to a relative one since from inside the container, you can't access the windows drives directly.
            – Pramodh Valavala
            Nov 14 at 17:27










          • I dont understand. What change to the WORKDIR do i need to make then?
            – Mike Hawkins
            Nov 14 at 18:04










          • The error is because the path where it's searching for project.assets.json is wrong. Try removing the bin and obj folders and also the --no-restore flag from your dockerfile.
            – Pramodh Valavala
            Nov 14 at 18:15










          • I tried it, however, VS Code prompts me to restore packages everytime i have made a change to the code, detected by the watcher. I would like to not have it need to restore packages upon every code change.
            – Mike Hawkins
            Nov 14 at 18:19




















          • Thank you for your reply, i have updated my original question. I now receive a new error
            – Mike Hawkins
            Nov 14 at 9:22










          • It's because you are using an absolute path to that asset. You will have to change it to a relative one since from inside the container, you can't access the windows drives directly.
            – Pramodh Valavala
            Nov 14 at 17:27










          • I dont understand. What change to the WORKDIR do i need to make then?
            – Mike Hawkins
            Nov 14 at 18:04










          • The error is because the path where it's searching for project.assets.json is wrong. Try removing the bin and obj folders and also the --no-restore flag from your dockerfile.
            – Pramodh Valavala
            Nov 14 at 18:15










          • I tried it, however, VS Code prompts me to restore packages everytime i have made a change to the code, detected by the watcher. I would like to not have it need to restore packages upon every code change.
            – Mike Hawkins
            Nov 14 at 18:19


















          Thank you for your reply, i have updated my original question. I now receive a new error
          – Mike Hawkins
          Nov 14 at 9:22




          Thank you for your reply, i have updated my original question. I now receive a new error
          – Mike Hawkins
          Nov 14 at 9:22












          It's because you are using an absolute path to that asset. You will have to change it to a relative one since from inside the container, you can't access the windows drives directly.
          – Pramodh Valavala
          Nov 14 at 17:27




          It's because you are using an absolute path to that asset. You will have to change it to a relative one since from inside the container, you can't access the windows drives directly.
          – Pramodh Valavala
          Nov 14 at 17:27












          I dont understand. What change to the WORKDIR do i need to make then?
          – Mike Hawkins
          Nov 14 at 18:04




          I dont understand. What change to the WORKDIR do i need to make then?
          – Mike Hawkins
          Nov 14 at 18:04












          The error is because the path where it's searching for project.assets.json is wrong. Try removing the bin and obj folders and also the --no-restore flag from your dockerfile.
          – Pramodh Valavala
          Nov 14 at 18:15




          The error is because the path where it's searching for project.assets.json is wrong. Try removing the bin and obj folders and also the --no-restore flag from your dockerfile.
          – Pramodh Valavala
          Nov 14 at 18:15












          I tried it, however, VS Code prompts me to restore packages everytime i have made a change to the code, detected by the watcher. I would like to not have it need to restore packages upon every code change.
          – Mike Hawkins
          Nov 14 at 18:19






          I tried it, however, VS Code prompts me to restore packages everytime i have made a change to the code, detected by the watcher. I would like to not have it need to restore packages upon every code change.
          – Mike Hawkins
          Nov 14 at 18:19




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238901%2fdotnet-watch-run-in-container-with-multi-project-solution%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Full-time equivalent

          Bicuculline

          さくらももこ