19

I'm getting an error when I build my docker.

Sending build context to Docker daemon 3.584 kB
Step 1/8 : FROM microsoft/aspnetcore:1.1
 ---> 2628aaa7b8cf
Step 2/8 : ENV ASPNETCORE_URLS "http://*:5000"
 ---> Using cache
 ---> 5dffde204fef
Step 3/8 : ENV ASPNETCORE_ENVIRONMENT "Development"
 ---> Using cache
 ---> 3064358bc0eb
Step 4/8 : ARG source
 ---> Using cache
 ---> 4159d0eb78c0
Step 5/8 : WORKDIR /app
 ---> Using cache
 ---> 61a394c84304
Step 6/8 : EXPOSE 5000
 ---> Using cache
 ---> c7c2309f7085
Step 7/8 : COPY ${source:-obj/Docker/publish} .
lstat obj/Docker/publish: no such file or directory

Here's my Dockerfile.

FROM microsoft/aspnetcore:1.1
ENV ASPNETCORE_URLS="http://*:5000"
ENV ASPNETCORE_ENVIRONMENT="Development"
ARG source
WORKDIR /app
EXPOSE 5000
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "ProjectTestApi.dll"

and I run a command:

$ docker build -t my-docker-image-test .

Do you have any ide what is wrong?

1
  • Have you tried my solution? Commented Apr 13, 2017 at 11:45

3 Answers 3

32

It's happening because you didn't published your solution. The error message is self-explanatory:

no such file or directory

By default, when you add Docker support to you ASP.NET Core Visual Studio 2017 project, it creates a bunch of docker-compose.yml files, one of them is docker-compose.ci.build.yml which handles the build process. Then, when you build the project through Visual Studio, full docker-compose pipeline is executed.

The contents of docker-compose.ci.build.yml, are similiar to this (it depends on custom config and project names obviously):

version: '2'

services:
  ci-build:
    image: microsoft/aspnetcore-build:1.0-1.1
    volumes:
      - .:/src
    working_dir: /src
    command: /bin/bash -c "dotnet restore ./SolutionName.sln && dotnet publish ./SolutionName.sln -c Release -o ./obj/Docker/publish"

As you can see in the last line, there is a dotnet publish command invoked, which actually builds & publishes your project.

So the solution for your issue, will be just building the project before calling docker:

dotnet publish ./SolutionName.sln -c Release -o ./obj/Docker/publish
docker build -t my-docker-image-test .
Sign up to request clarification or add additional context in comments.

2 Comments

I have the same problem. Where should I add those two lines? In Dockerfile for my project?
@GSPdibbler These are command line commands so the same place you would run the docker CLI. Probably a bat file.
3

When you use the option "Add Docker Support" in Visual Studio 2017, VS generates a bunch of docker-compose files and Dockerfiles. As Marcin Zablocki mentioned, one of these is docker-compose.ci.build.yml.

To stay in line with the Docker philosophy, you can use a docker container to publish your project. To publish your project you would take the following steps:

  1. git clone/pull your project & cd into the root dir
  2. Publish your project with docker-compose -f docker-compose.ci.build.yml up
  3. Start your project with docker-compose up

I have encountered situations where the Dockerfile of your main project is giving problems. This happens with FROM microsoft/aspnetcore:1.1, you can change it to FROM microsoft/aspnetcore:1.1.2 or whatever version is needed for your project.

2 Comments

VS.net 2017 17.4 does not create docker-compose.ci.build.yml nor does it call for this file from the commandline it generates. Anyone have an idea how this now works because it's still broken.
As far as I can tell, this command works ok (copying from the output window of VS2017) docker-compose -f "docker-compose.yml" -f "docker-compose.override.yml" -p dockercompose17560113652152234329 --no-ansi build
0

If you have published your project and facing this issue because of directory error, just move the docker file one folder up and put it beside *.sln file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.