JetBrains / teamcity-docker-agent

TeamCity agent docker image sources
https://hub.docker.com/r/jetbrains/teamcity-agent/
Apache License 2.0
77 stars 64 forks source link

Failed to initialize CoreCLR, HRESULT: 0x80004005 #45

Open bdaniel7 opened 5 years ago

bdaniel7 commented 5 years ago

Hi,

I'm trying to run a TeamCity agent in a container. This is environment:

The TeamCity and the agent are the latest from the container (2018.1.3 (build 58658)) The container is run in Docker for Windows, using Linux containers (because the production will run on Ubuntu).

root@teamcity-agent3:/opt/buildagent/work/70bf5e8b1cc61bbe/src# dotnet --info .NET Core SDK (reflecting any global.json): Version: 2.1.401 Commit: 91b1c13032

Runtime Environment: OS Name: ubuntu OS Version: 16.04 OS Platform: Linux RID: ubuntu.16.04-x64 Base Path: /usr/share/dotnet/sdk/2.1.401/

Host (useful for support): Version: 2.1.3 Commit: 124038c13e

.NET Core SDKs installed: 2.1.401 [/usr/share/dotnet/sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

When I run the build using

/opt/buildagent/work/70bf5e8b1cc61bbe/src# /usr/bin/dotnet build trains.sln --framework netcoreapp2.1 --configuration Release --runtime ubuntu-x64

in the container, the build is successful.

However when I run the same command as part of a build step, I get this error:

Failed to initialize CoreCLR, HRESULT: 0x80004005

Any ideas on why this error occurs?

bdaniel7 commented 5 years ago

I think this occurs because the teamcity agent runs under buildagent user and the folders and files created during agent instalation (/opt, /tmp) are rw only for root:root.

I tried to add root to group docker and set chown those directories to root:docker but to no avail. New folders generated when the any "dotnet" command starts are owned and rw by root.

1scrooge commented 5 years ago

I have the same issue. Any ideas?

bdaniel7 commented 5 years ago

One workaround is to set the environment variable COMPlus_EnableDiagnostics=0 in all the containers where dotnet runs. The variable is used to determine whether the clr will write some debug information in /tmp. You can search for more details about that variable in the .NET Core GitHub issues log.

1scrooge commented 5 years ago

@bdaniel7 Thank you. It`s helped

NikolayPianikov commented 5 years ago

@bdaniel7 could you share commands which are used to run TeamCity server and agent in docker?

bdaniel7 commented 5 years ago

They are run using docker-compose: teamcity-server: restart: always image: jetbrains/teamcity-server:latest container_name: teamcity hostname: 'teamcity' depends_on:

NikolayPianikov commented 5 years ago

@bdaniel7 by default TeamCity agent uses this TEMP directory TMPDIR=/opt/buildagent/temp/buildTmp. Try using the same.