I am having a strange issue with compose since yesterday (01.12.), where my docker-compose can’t read the Dockerfile. The issue appeared out of the blue because the code hasn’t changed but the build started to fail.
My docker-compose:
service1:
image: service1-image
build:
context: ${SERVICE1_DIR}
dockerfile: \src\Service1.Service\Service1.Service.Web\Dockerfile-Development
ports:
- "${HTTP_SERVICE1_PORT}:80"
- "${HTTPS_SERVICE1_PORT}:443"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+;http://+
- ASPNETCORE_HTTPS_PORT=${HTTPS_SERVICE1_PORT}
- ASPNETCORE_ConnectionStrings__SQLServer=Server=sqlserver;Database=Service1;User ID=sa;Password=****
- ASPNETCORE_Kestrel__Certificates__Default__Password=${CERT_PASSWORD}
- ASPNETCORE_Kestrel__Certificates__Default__Path=${SERVICE1_CERT_PATH}
volumes:
- ${DOCKER_DIR}\https:/https/:ro
There is no issue with the Dockerfile-Development itself because I am able to build the image directly by using docker build command. Also, if I change it to Dockerfile the error is the same.
SERVICE1_DIR is the path to the root of the folder (solution) and then
I am extending the path to dockerfile which is located where my Web
API project is. There are a couple of Class Library project on which
my API has a dependency on. All of which I am referencing in my
dockerfile without any issue.
My environment:
- docker-compose file version: 3.4
- docker version: Docker version 20.10.11, build dea9396
I am using .NET SDK 6.0 and ASPNET 6.0 runtime.
Here is the error:
=> ERROR [internal] load build definition from Dockerfile-Development
0.1s
=> => transferring dockerfile: 79B
0.0s
=> [internal] load .dockerignore
0.1s
=> => transferring context: 35B
0.0s
------
[internal] load build definition from Dockerfile-Development:
------
failed to solve with frontend dockerfile.v0: failed to read dockerfile: error from
sender: resolve : CreateFile \\?\C:\src: The system cannot find the file specified.
ERROR: Service 'service1' failed to build : Build failed
** UPDATE WITH SOLUTION **
Resolved the issue with adding the missing part of the path to dockerfile in build
Working docker-compose file:
service1:
image: service1-image
build:
context: ${SERVICE1_DIR}
dockerfile: ${SERVICE1_DIR}\src\Service1.Service\Service1.Service.Web\Dockerfile-Development
ports:
- "${HTTP_SERVICE1_PORT}:80"
- "${HTTPS_SERVICE1_PORT}:443"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+;http://+
- ASPNETCORE_HTTPS_PORT=${HTTPS_SERVICE1_PORT}
- ASPNETCORE_ConnectionStrings__SQLServer=Server=sqlserver;Database=Service1;User ID=sa;Password=****
- ASPNETCORE_Kestrel__Certificates__Default__Password=${CERT_PASSWORD}
- ASPNETCORE_Kestrel__Certificates__Default__Path=${SERVICE1_CERT_PATH}
volumes:
- ${DOCKER_DIR}\https:/https/:ro