Multistage docker build not working
goldytech opened this issue · 11 comments
Hi,
I'm trying to create a docker image using docker multi stage build feature. I'm getting error in RUN dotnet build -c Release --no-restore
. It gives error
/usr/share/dotnet/sdk/2.0.3/Microsoft.Common.CurrentVersion.targets(1988,5): warning MSB3245: Could not resolvethis reference. Could not locate the assembly "MongoDB.Bson, Version=2.4.4.0, Culture=neutral, PublicKeyToken=null". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/sln/src/LF-Tenant.Abstractions/LF-Tenant.Abstractions.csproj]
Models/Tenant.cs(1,7): error CS0246: The type or namespace name 'MongoDB' could not be found (are you missing ausing directive or an assembly reference?) [/sln/src/LF-Tenant.Abstractions/LF-Tenant.Abstractions.csproj]
Models/Tenant.cs(8,10): error CS0246: The type or namespace name 'BsonIdAttribute' could not be found (are you missing a using directive or an assembly reference?) [/sln/src/LF-Tenant.Abstractions/LF-Tenant.Abstractions.csproj]
Basically it is not able to find the Mongo Nuget package. Though dotnet restore
was run in prior step.
I have put my code on https://github.com/goldytech/LF-Tenant
Can you please help me where I m going wrong ?
Thanks
@goldytech - It looks like a couple of the NuGet package references are not defined correctly.
If these are changed to be like the one at https://github.com/goldytech/LF-Tenant/blob/master/src/LF-Tenant.Api/LF-Tenant.Api.csproj#L10, I think your Dockerfile will build.
Issue was resolved - closing issue.
Hi,
Multistage build is not working on my machine. Everytime I am getting the same error at the very last step which is copying the output from the first stage. I am using the Docker file from the "dotnetapp-prod" folder of this repository itself.
Step 9/10 : COPY --from=build-env /app/out ./
COPY failed: failed to open file /tmp/856ded49f0f4c963f67dcd5a8763a06fac9c4b3e976f9ed2b4e9229dc169e45d-mount/app/out: invalid arguments.
I am using Docker for Windows Edge version with "Enable Linux Containers for Windows" feature enabled.
Thanks,
Ajay
Ajay, could you paste the output from the following two commands -
docker version
docker info
This will help me reproduce the issue locally.
Hi,
Below is the info
- Docker version
Docker version 17.12.0-ce-rc3, build 80c8033
- Docker info
Containers: 6
Running: 0
Paused: 0
Stopped: 6
Images: 31
Server Version: 17.12.0-ce-rc3
Storage Driver: windowsfilter (windows) lcow (linux)
LCOW:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics l2bridge l2tunnel nat null overlay transparent
Log: awslogs etwlogs fluentd gelf json-file logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 16299 (16299.15.amd64fre.rs3_release.170928-1534)
Operating System: Windows 10 Enterprise
OSType: windows
Architecture: x86_64
CPUs: 4
Total Memory: 11.88GiB
Name: <Machine-Name>
ID: KKFL:G4XJ:NIB6:RCPK:NAPI:7ULM:WI4X:ORDL:46OI:2QT6:7IW3:3GBW
Docker Root Dir: C:\ProgramData\Docker\lcow
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: -1
Goroutines: 27
System Time: 2017-12-21T11:47:11.7078706+05:30
EventsListeners: 0
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Thanks,
Ajay
Thanks Ajay. I installed the same version (7.12.0-ce-rc3), and tried the sample. It seems to work fine. Pasted below relevant portion of console output of build command, and Docker version.
Step 9/10 : COPY --from=build-env /app/out ./
---> e0747f5d6744
Step 10/10 : ENTRYPOINT ["dotnet", "dotnetapp.dll"]
---> Running in ecd8ba4ea8be
Removing intermediate container ecd8ba4ea8be
---> 305faec07846
Successfully built 305faec07846
Successfully tagged dotnetapp-prod:latest
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
D:\dotnet-docker-samples\dotnetapp-prod>docker version
Client:
Version: 17.12.0-ce-rc3
API version: 1.35
Go version: go1.9.2
Git commit: 80c8033
Built: Thu Dec 14 00:39:41 2017
OS/Arch: windows/amd64
Server:
Engine:
Version: 17.12.0-ce-rc3
API version: 1.35 (minimum version 1.12)
Go version: go1.9.2
Git commit: 80c8033
Built: Thu Dec 14 00:45:43 2017
OS/Arch: linux/amd64
Experimental: true
Please could you confirm if you are using the Dockerfile (https://github.com/dotnet/dotnet-docker-samples/blob/**master**/dotnetapp-prod/Dockerfile), and there are no local changes.
I have not make any local changes. Also looking your docker version I noticed one thing on my machine that my docker server OS/Arch section is showing windows rather than linux. same thing happen with docker info (already shared earlier) command where OSType is windows.
C:\TestProjects\kubernetesDemo\dotnet-docker-samples\dotnetapp-prod>docker version
Client:
Version: 17.12.0-ce-rc3
API version: 1.35
Go version: go1.9.2
Git commit: 80c8033
Built: Thu Dec 14 00:39:41 2017
OS/Arch: windows/amd64
Server:
Engine:
Version: 17.12.0-ce-rc3
API version: 1.35 (minimum version 1.24)
Go version: go1.9.2
Git commit: 80c8033
Built: Thu Dec 14 00:49:52 2017
OS/Arch: windows/amd64
Experimental: true
Seems I am missing some installation step. Can you please help on this?
Thanks Ajay. Docker for Windows provides the option to switch between Windows and Linux containers (https://docs.docker.com/docker-for-windows/#switch-between-windows-and-linux-containers). The sample app works fine with either option.
I am able to reproduce the issue on one of my machines. The key step to reproduce the issue is to enable Linux Containers on Windows (LCOW). More about this here. I will investigate further to understand if this is one of the known issues.
Meanwhile, to get you unblocked, please try one of the following options -
-
Disable LCOW. How to do this is described here
-
Use
Stable
version of Docker (https://docs.docker.com/docker-for-windows/install/).
Please give it a try, and let me know how it goes.
After disabling the "Linux Containers on Windows (LCOW)" on my windows 10 machine things start working file.
Step 9/10 : COPY --from=build-env /app/out ./
---> 71b20fed307a
Step 10/10 : ENTRYPOINT ["dotnet", "dotnetapp.dll"]
---> Running in 1d137704788a
Removing intermediate container 1d137704788a
---> a5f596a78b2f
Successfully built a5f596a78b2f
Successfully tagged dotnetapp-prod:latest
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
So it seems there is some bug with the feature "Linux Containers on Windows (LCOW)".
Thanks for confirming.
Closing issue - original issue was resolved. Secondary issue is related to LCOW which is a docker issue.