Unable to find image 'xxxx' locally - docker

Basically I created an asp.net mvc project. I added a Dockerfile in the project folder.
FROM microsoft/aspnet:1.0.0-rc1-update1
ADD . /app
WORKDIR /app/approot
EXPOSE 5004
ENTRYPOINT ["./web"]
Now I open Docker Quickstart Terminal on my Windows desktop. Running the command
docker build -t hellodocker:0.1.0 .
See the result
However I can't find the image when I run it.
So what is wrong?
EDIT
Thanks for the comment, I correct the typo. But there is an another error.
EDIT-1
If I change the ENTRYPOINT as ENTRYPOINT ["dnx", "-p", "project.json", "web"]
Then I get another error:
Unable to reslolve project from /app/approot
EDIT-2
The context in the directory is as:

Your project is being added to the image as /app. So, in the container, the project.json lives at /app/project.json. But your WORKDIR is set to /app/approot.
This effectively makes your ENTRYPOINT looking for project.json at /app/approot, which it does not exist. You'll either need to change WORKDIR to /app or COPY . /app/approot.

Related

docker - Copy bin directory , folder not found

I have a dockerfile for my .net 6 project that just has the following:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
EXPOSE 8081
COPY bin/Release/net6/ App/
WORKDIR /App
ENTRYPOINT ["dotnet", "IdentityManager.dll"]
but when i try to build this, i get an error that the 'bin/Release/net6' folder isn't found. See the attached image to see my build command, and the file explorer showing that the folder does indeed exist. Is there something going on here that i'm not seeing? Thanks!

Docker - cannot build simple dotnet webapi container: COPY failed: stat /var/lib/docker/overlay2 error

I've created a simple .NET Core 3.0 web API. In the project directory, I have a Dockerfile that looks like this:
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-env
WORKDIR /app
# copy over csproj and restore nuget packages
COPY DockerWebApiSandbox.csproj ./
RUN dotnet restore
# copy everything else over into the same directory as the last copy step
# and run the publish step to build and gather output
COPY . ./
RUN dotnet publish -c Release -o output
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "DockerWebApiSandbox.dll"]
When running docker build -t dockerwebapisandbox . from the working directory of my project, I see a failure on step 9 of 10 (third COPY command):
COPY failed: stat
/var/lib/docker/overlay2/f6f3391827aef74f1dab5716635a9119ae250ae94a216bbc0bc7b47c4030d60a/merged/app/out:
no such file or directory
When searching what the community was saying about this error, I found a suggestion here. The suggestion mentions screening into the VM, but this command fails, given that the com.docker.driver.amd64-linux/ directory does not exist where it's being expected. The screen command suggested looks like this: $ screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
Other than trying the suggestion from the link above, I've tried uninstalling Docker and Docker Desktop altogether, in addition to the "Factory Reset" option provided in Docker Desktop.
FWIW, I am running MacOS Mojave. TIA for anyone who has suggestions.
I have faced the same error in Node. I was resolve using
COPY . .

Can not copy files properly to docker image

Hello i am trying to recreate inside a docker image my host folder that contains:
Publish (folder containing a .NET app )
dockerfile
conf.json
dockerfile
FROM microsoft/aspnetcore
WORKDIR /app
ADD . /app
ENTRYPOINT ["dotnet","/publish/Bench.dll"]
EXPOSE 8300
When i am trying to see what it created using docker exec -it <id> bash it just takes all the content of publish and throws it inside app without copying conf.json.
I have also tried with
COPY . /app,
COPY /publish /app+COPY conf.json /app to no avail.
Whatever i am trying it won't copy the folder as-is and it wont put the json file beside it.
What am i doing wrong?
So I tested this out. I had the publish folder dockerfile and conf.json in the same directory where I build the image from. That is the key. Here I am using nginx as my base image. The following is the command I used to build the nginx image
docker build -t test/nginx .
and the dockerfile is as below. So I create the app directory by using the RUN command. You will have to use the similar command in .net to create that directory if it doesn't exist. Also pay attention to the docker build logs. It will tell you things that are important. Also you could add an ls command in the dockerfile to list the files in the folder /app if you want to.
FROM nginx
RUN mkdir /app
WORKDIR /app
ADD . /app
After I create a container from the image I built, i can navigate to /app folder and view my
Dockerfile, config.json and publish folder in there. Hope this helps
Let me know if you have any questions

Docker - Getting error while trying to build image

I am new with docker, trying to create my first docker image/container with .net core console application in Windows 10, following the article https://www.c-sharpcorner.com/article/getting-started-with-docker-for-windows-containerize-a-c-sharp-console-app/
I am getting the error message when building image:
COPY /bin/Debug/netcoreapp2.0/publish/ . COPY failed: CreateFile \\?\C:\ProgramData\Docker\tmp\docker-builder989987487\bin
The content of my Dockerfile:
FROM microsoft/dotnet:2.0.4-runtime-nanoserver-1709 AS base
WORKDIR /app
COPY /bin/Debug/netcoreapp2.0/publish/ .
ENTRYPOINT ["dotnet", "ConsoleApp1.dll"]
C:\DotNetCore\ConsoleApp1\ConsoleApp1 is the root of my folder,
where I palced above Dockerfile.
C:\DotNetCore\ConsoleApp1\ConsoleApp1\bin\Debug\netcoreapp2.1\publish
is the folder where content is get published by dotnet publish
command.
Command used to create the image:
docker build -t alphaimage .
You can try this, by removing the first / in the source directory of COPY:
FROM microsoft/dotnet:2.0.4-runtime-nanoserver-1709 AS base
WORKDIR /app
COPY bin/Debug/netcoreapp2.1/publish/ /app
ENTRYPOINT ["dotnet", "ConsoleApp1.dll"]
You are publishing to a folder that has netcoreapp2.1 in its name and the dockerfile is looking for a folder with netcoreapp2.0 in its name.
EITHER:
Change your csproj to use netcoreapp2.0:
<TargetFramework>netcoreapp2.0</TargetFramework>
OR
Update your COPY statement to use netcoreapp2.1
COPY /bin/Debug/netcoreapp2.1/publish/ .

Docker and VS Mac

Following the instructions on Docker's page I created a very simple Dockerfile that looks like this:
FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "dockertest.dll"]
This is literally a copy of the sample on Docker's site just changed the application name.
I used Visual Studio for Mac to create a very simple ASP.Net application (actually, just the default app with a tiny HTML file added in).
When I first ran docker build -t dockertest . the line with dotnet publish failed. I then ran the dotnet publish manually and got past that.
It now fails on the copy:
Step 9/10 : COPY --from=build-env /app/out .
COPY failed: stat /var/lib/docker/overlay2/1484306cebf1def83638270757e70a8cf874fb5a167f39e5bfaae92a47cc071c/merged/app/out: no such file or directory
What's going on?
So did you run dotnet publish inside the container or on the host machine? The Docker file is trying to run those commands inside the container, so running those on the host will not fix the issue.
Have you tried to right click your project and "Add Docker Support" to your app in VS for Mac? It should generate a docker file and then you can run/debug your app inside the container from within VS.

Resources