Error copying files from host to container

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.

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

When you build the Dockerfile on its own, do you do something like

cd nginx
docker build -t avboivin/nginx

that would correspond to

build:
  context: nginx

Thank you so much for giving me a hand with this David !

I figured out a way to get around this bug maybe 2 minutes ago tops.

You are right, running the dockerfile by itself worked fine but running it with docker-compose failed.

Something I changed that fixed the issue was to have the Dockerfile in the same folder as the docker-compose.yaml

This is where I found it :