Why is Docker-compose failing to copy local files to the container












0















I am building a simple DotnetCore application with docker-compose support with VS2017.



I have two Dockerfile, one for the app and one for an NGINX proxy.
On top of that, there is a docker-compose.yml file that wraps both of these together.



This is the aspnetcore app Dockerfile, there's many COPY statement in there and they all work properly!



FROM microsoft/dotnet:2.0-runtime AS base
WORKDIR /app

FROM microsoft/dotnet:2.0-sdk AS build
WORKDIR /src
COPY CoreServer.sln ./
COPY CoreServer/CoreServer.csproj CoreServer/
RUN dotnet restore -nowarn:msb3202,nu1503
COPY . .
WORKDIR /src/CoreServer
RUN dotnet build -c Release -o /app

FROM build AS publish
RUN dotnet publish -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "CoreServer.dll"]


This is the nginx Dockerfile which can't manage to copy files properly. Instead, it outputs the following error:



COPY failed: stat /var/lib/docker/tmp/docker-builder780242597/nginx.conf: no such file or directory. #1859



FROM nginx

WORKDIR /etc/nginx

COPY nginx.conf ./
COPY server.crt ./
COPY server.key ./


I tried building this Dockerfile by itself and it works, but when I use docker-compose it gives the error above.



This is what the docker-compose.yml file looks like



version: '3'

services:
coreserver:
image: coreserver
build:
context: .
dockerfile: CoreServer/Dockerfile
expose:
- "5000"

nginx:
build:
context: .
dockerfile: nginx/Dockerfile
ports:
- "80:80"
- "443:443"
links:
- coreserver


If you want to look at the full project, it's a dotnetcore websocket server test application with a server and a client application.



https://github.com/avboivin/WssCoreServer/tree/master/server



Can somebody tell me what I'm doing wrong to have docker send give this particular error ?










share|improve this question



























    0















    I am building a simple DotnetCore application with docker-compose support with VS2017.



    I have two Dockerfile, one for the app and one for an NGINX proxy.
    On top of that, there is a docker-compose.yml file that wraps both of these together.



    This is the aspnetcore app Dockerfile, there's many COPY statement in there and they all work properly!



    FROM microsoft/dotnet:2.0-runtime AS base
    WORKDIR /app

    FROM microsoft/dotnet:2.0-sdk AS build
    WORKDIR /src
    COPY CoreServer.sln ./
    COPY CoreServer/CoreServer.csproj CoreServer/
    RUN dotnet restore -nowarn:msb3202,nu1503
    COPY . .
    WORKDIR /src/CoreServer
    RUN dotnet build -c Release -o /app

    FROM build AS publish
    RUN dotnet publish -c Release -o /app

    FROM base AS final
    WORKDIR /app
    COPY --from=publish /app .
    ENTRYPOINT ["dotnet", "CoreServer.dll"]


    This is the nginx Dockerfile which can't manage to copy files properly. Instead, it outputs the following error:



    COPY failed: stat /var/lib/docker/tmp/docker-builder780242597/nginx.conf: no such file or directory. #1859



    FROM nginx

    WORKDIR /etc/nginx

    COPY nginx.conf ./
    COPY server.crt ./
    COPY server.key ./


    I tried building this Dockerfile by itself and it works, but when I use docker-compose it gives the error above.



    This is what the docker-compose.yml file looks like



    version: '3'

    services:
    coreserver:
    image: coreserver
    build:
    context: .
    dockerfile: CoreServer/Dockerfile
    expose:
    - "5000"

    nginx:
    build:
    context: .
    dockerfile: nginx/Dockerfile
    ports:
    - "80:80"
    - "443:443"
    links:
    - coreserver


    If you want to look at the full project, it's a dotnetcore websocket server test application with a server and a client application.



    https://github.com/avboivin/WssCoreServer/tree/master/server



    Can somebody tell me what I'm doing wrong to have docker send give this particular error ?










    share|improve this question

























      0












      0








      0








      I am building a simple DotnetCore application with docker-compose support with VS2017.



      I have two Dockerfile, one for the app and one for an NGINX proxy.
      On top of that, there is a docker-compose.yml file that wraps both of these together.



      This is the aspnetcore app Dockerfile, there's many COPY statement in there and they all work properly!



      FROM microsoft/dotnet:2.0-runtime AS base
      WORKDIR /app

      FROM microsoft/dotnet:2.0-sdk AS build
      WORKDIR /src
      COPY CoreServer.sln ./
      COPY CoreServer/CoreServer.csproj CoreServer/
      RUN dotnet restore -nowarn:msb3202,nu1503
      COPY . .
      WORKDIR /src/CoreServer
      RUN dotnet build -c Release -o /app

      FROM build AS publish
      RUN dotnet publish -c Release -o /app

      FROM base AS final
      WORKDIR /app
      COPY --from=publish /app .
      ENTRYPOINT ["dotnet", "CoreServer.dll"]


      This is the nginx Dockerfile which can't manage to copy files properly. Instead, it outputs the following error:



      COPY failed: stat /var/lib/docker/tmp/docker-builder780242597/nginx.conf: no such file or directory. #1859



      FROM nginx

      WORKDIR /etc/nginx

      COPY nginx.conf ./
      COPY server.crt ./
      COPY server.key ./


      I tried building this Dockerfile by itself and it works, but when I use docker-compose it gives the error above.



      This is what the docker-compose.yml file looks like



      version: '3'

      services:
      coreserver:
      image: coreserver
      build:
      context: .
      dockerfile: CoreServer/Dockerfile
      expose:
      - "5000"

      nginx:
      build:
      context: .
      dockerfile: nginx/Dockerfile
      ports:
      - "80:80"
      - "443:443"
      links:
      - coreserver


      If you want to look at the full project, it's a dotnetcore websocket server test application with a server and a client application.



      https://github.com/avboivin/WssCoreServer/tree/master/server



      Can somebody tell me what I'm doing wrong to have docker send give this particular error ?










      share|improve this question














      I am building a simple DotnetCore application with docker-compose support with VS2017.



      I have two Dockerfile, one for the app and one for an NGINX proxy.
      On top of that, there is a docker-compose.yml file that wraps both of these together.



      This is the aspnetcore app Dockerfile, there's many COPY statement in there and they all work properly!



      FROM microsoft/dotnet:2.0-runtime AS base
      WORKDIR /app

      FROM microsoft/dotnet:2.0-sdk AS build
      WORKDIR /src
      COPY CoreServer.sln ./
      COPY CoreServer/CoreServer.csproj CoreServer/
      RUN dotnet restore -nowarn:msb3202,nu1503
      COPY . .
      WORKDIR /src/CoreServer
      RUN dotnet build -c Release -o /app

      FROM build AS publish
      RUN dotnet publish -c Release -o /app

      FROM base AS final
      WORKDIR /app
      COPY --from=publish /app .
      ENTRYPOINT ["dotnet", "CoreServer.dll"]


      This is the nginx Dockerfile which can't manage to copy files properly. Instead, it outputs the following error:



      COPY failed: stat /var/lib/docker/tmp/docker-builder780242597/nginx.conf: no such file or directory. #1859



      FROM nginx

      WORKDIR /etc/nginx

      COPY nginx.conf ./
      COPY server.crt ./
      COPY server.key ./


      I tried building this Dockerfile by itself and it works, but when I use docker-compose it gives the error above.



      This is what the docker-compose.yml file looks like



      version: '3'

      services:
      coreserver:
      image: coreserver
      build:
      context: .
      dockerfile: CoreServer/Dockerfile
      expose:
      - "5000"

      nginx:
      build:
      context: .
      dockerfile: nginx/Dockerfile
      ports:
      - "80:80"
      - "443:443"
      links:
      - coreserver


      If you want to look at the full project, it's a dotnetcore websocket server test application with a server and a client application.



      https://github.com/avboivin/WssCoreServer/tree/master/server



      Can somebody tell me what I'm doing wrong to have docker send give this particular error ?







      docker docker-for-windows






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 20 '18 at 14:05









      A_VA_V

      11115




      11115






















          2 Answers
          2






          active

          oldest

          votes


















          2














          From https://docs.docker.com/engine/reference/builder/#copy. says :




          COPY obeys the following rules:




          • The [src] path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.


          • If [src] is a directory, the entire contents of the directory are copied, including filesystem metadata.





          so it's not bugs . COPY cannot read files from your absolute path.



          so the solution is to create your docker-compose.yml in same directory with your SOURCE dir/files and run it.






          share|improve this answer































            1














            It would seem this is a bug.



            I found the solution here :



            https://github.com/docker/for-mac/issues/1922#issuecomment-355364451



            Which was simply moving the Dockerfile that was having issues at the root level of the docker-compose.yaml file.






            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "3"
              };
              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',
              autoActivateHeartbeat: false,
              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%2fsuperuser.com%2fquestions%2f1306127%2fwhy-is-docker-compose-failing-to-copy-local-files-to-the-container%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2














              From https://docs.docker.com/engine/reference/builder/#copy. says :




              COPY obeys the following rules:




              • The [src] path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.


              • If [src] is a directory, the entire contents of the directory are copied, including filesystem metadata.





              so it's not bugs . COPY cannot read files from your absolute path.



              so the solution is to create your docker-compose.yml in same directory with your SOURCE dir/files and run it.






              share|improve this answer




























                2














                From https://docs.docker.com/engine/reference/builder/#copy. says :




                COPY obeys the following rules:




                • The [src] path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.


                • If [src] is a directory, the entire contents of the directory are copied, including filesystem metadata.





                so it's not bugs . COPY cannot read files from your absolute path.



                so the solution is to create your docker-compose.yml in same directory with your SOURCE dir/files and run it.






                share|improve this answer


























                  2












                  2








                  2







                  From https://docs.docker.com/engine/reference/builder/#copy. says :




                  COPY obeys the following rules:




                  • The [src] path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.


                  • If [src] is a directory, the entire contents of the directory are copied, including filesystem metadata.





                  so it's not bugs . COPY cannot read files from your absolute path.



                  so the solution is to create your docker-compose.yml in same directory with your SOURCE dir/files and run it.






                  share|improve this answer













                  From https://docs.docker.com/engine/reference/builder/#copy. says :




                  COPY obeys the following rules:




                  • The [src] path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.


                  • If [src] is a directory, the entire contents of the directory are copied, including filesystem metadata.





                  so it's not bugs . COPY cannot read files from your absolute path.



                  so the solution is to create your docker-compose.yml in same directory with your SOURCE dir/files and run it.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 17 at 9:27









                  guhkun13guhkun13

                  213




                  213

























                      1














                      It would seem this is a bug.



                      I found the solution here :



                      https://github.com/docker/for-mac/issues/1922#issuecomment-355364451



                      Which was simply moving the Dockerfile that was having issues at the root level of the docker-compose.yaml file.






                      share|improve this answer




























                        1














                        It would seem this is a bug.



                        I found the solution here :



                        https://github.com/docker/for-mac/issues/1922#issuecomment-355364451



                        Which was simply moving the Dockerfile that was having issues at the root level of the docker-compose.yaml file.






                        share|improve this answer


























                          1












                          1








                          1







                          It would seem this is a bug.



                          I found the solution here :



                          https://github.com/docker/for-mac/issues/1922#issuecomment-355364451



                          Which was simply moving the Dockerfile that was having issues at the root level of the docker-compose.yaml file.






                          share|improve this answer













                          It would seem this is a bug.



                          I found the solution here :



                          https://github.com/docker/for-mac/issues/1922#issuecomment-355364451



                          Which was simply moving the Dockerfile that was having issues at the root level of the docker-compose.yaml file.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 21 '18 at 2:28









                          A_VA_V

                          11115




                          11115






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Super User!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1306127%2fwhy-is-docker-compose-failing-to-copy-local-files-to-the-container%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

                              flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                              Mangá

                              Eduardo VII do Reino Unido