Search code examples
docker.net-coredocker-composemicroservicesvisual-studio-2019

Docker ADD command produces 'cannot find the file' error


I'm trying to move my few microservices to a docker containers using docker-compose project type from Visual Studio.

I also have Service Fabric project so I have to install Service Fabric SDK into my docker containers.

That's what I do to achieve this (my dockerfile(s)):

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-nanoserver-1809 AS base
WORKDIR /app
EXPOSE 80

...

WORKDIR /temp

ADD https://aka.ms/vs/15/release/vs_buildtools.exe /temp #C:\TEMP\vs_buildtools.exe

...

The rest code doesn't matter since it crashes on line with ADD command. The error from Output after I run this via Ctrl+F5:

3>Step 4/11 : ADD https://aka.ms/vs/15/release/vs_buildtools.exe /temp
3>Service 'bmt.microservices.snowforecastcenter' failed to build: ADD failed: CreateFile \\?\C:\ProgramData\Docker\tmp\docker-builder567273413\temp: The system cannot find the file specified.

I don't understand what I'm doing wrong and what does it mean 'system cannot find the file' since I simply load the file from the internet and place it into my newly created \temp folder (the link is valid, I checked).

Does anybody know what this might be related to?


Solution

  • Ok, I've accidentally fixed the problem by moving comment to next line.

    From this:

    ADD https://aka.ms/vs/15/release/vs_buildtools.exe /temp #C:\TEMP\vs_buildtools.exe
    

    To this:

    ADD https://aka.ms/vs/15/release/vs_buildtools.exe /temp
    #C:\TEMP\vs_buildtools.exe
    

    Then I red on official site (https://docs.docker.com/engine/reference/builder/#/from) that you cannot have inline comments since they are treated as arguments:

    Docker treats lines that begin with # as a comment, unless the line is a valid parser directive. A # marker anywhere else in a line is treated as an argument.

    I hope this will help other people who are new in Docker.