0
votes

I am trying to get a TeamCity Linux Agent setup within docker. The Agent needs to be able to build dotnet core 2 apps and then do a docker build on the app.

I have Docker running under Windows 10 atm but the plan is that the container will run under Linux in AWS.

I have gotten the TC Agent container up and running, dotnet stuff sorted but am stuck on the docker stuff.

The following is the TC agent log:

[08:33:47]Step 2/2: Docker Build (2m:16s)
[08:33:48][Step 2/2] Starting: docker build --pull -f Dockerfile .
[08:33:48][Step 2/2] in directory: /opt/buildagent/work/274731defed46d9f/think.ETL
[08:33:48][Step 2/2] 
[08:33:48][Step 2/2] Step 1/9 : FROM microsoft/aspnetcore:2.0.4
[08:33:51][Step 2/2] 2.0.4: Pulling from microsoft/aspnetcore
[08:33:52][Step 2/2] 723254a2c089: Pulling fs layer
[08:33:52][Step 2/2] 499be8ca2075: Pulling fs layer
[08:33:52][Step 2/2] a6854c900e79: Pulling fs layer
[08:33:52][Step 2/2] 36653ffe7e35: Pulling fs layer
[08:33:52][Step 2/2] 2c2c279d1b1a: Pulling fs layer
[08:33:52][Step 2/2] 36653ffe7e35: Waiting
[08:33:52][Step 2/2] 2c2c279d1b1a: Waiting
[08:33:54][Step 2/2] a6854c900e79: Download complete
[08:35:02][Step 2/2] 36653ffe7e35: Verifying Checksum
[08:35:02][Step 2/2] 36653ffe7e35: Download complete
[08:35:30][Step 2/2] 499be8ca2075: Verifying Checksum
[08:35:30][Step 2/2] 499be8ca2075: Download complete
[08:35:41][Step 2/2] 2c2c279d1b1a: Verifying Checksum
[08:35:41][Step 2/2] 2c2c279d1b1a: Download complete
[08:35:54][Step 2/2] 723254a2c089: Verifying Checksum
[08:35:54][Step 2/2] 723254a2c089: Download complete
[08:35:58][Step 2/2] 723254a2c089: Pull complete
[08:35:59][Step 2/2] 499be8ca2075: Pull complete
[08:36:00][Step 2/2] a6854c900e79: Pull complete
[08:36:01][Step 2/2] 36653ffe7e35: Pull complete
[08:36:04][Step 2/2] 2c2c279d1b1a: Pull complete
[08:36:04][Step 2/2] Digest: sha256:0a54eac597bdb205f3023410741d7492dcb52cf9a5b1f917755dc755339e4002
[08:36:04][Step 2/2] Status: Downloaded newer image for microsoft/aspnetcore:2.0.4
[08:36:04][Step 2/2]  ---> e49b04bf00d5
[08:36:04][Step 2/2] Step 2/9 : ARG source
[08:36:04][Step 2/2] error creating aufs mount to /var/lib/docker/aufs/mnt/ccc81e8c41476a5f72ea23ffc7222ba9b65c47b032a389db9acec26730d1a114-init: invalid argument
[08:36:04][Step 2/2] error creating aufs mount to /var/lib/docker/aufs/mnt/ccc81e8c41476a5f72ea23ffc7222ba9b65c47b032a389db9acec26730d1a114-init: invalid argument
[08:36:04][Step 2/2] Process exited with code 1
[08:36:04][Step 2/2] Process exited with code 1
[08:36:04][Step 2/2] Step Docker Build failed

These are my instructions to get where I am up to

-- Install TC Agent - https://hub.docker.com/r/jetbrains/teamcity-agent/

  • docker run -it --name teamcity-agent-linux -e SERVER_URL="http://192.168.50.217:8111" -v D:\TeamCity\Agent\conf:/data/teamcity_agent/conf --privileged -e DOCKER_IN_DOCKER="start" jetbrains/teamcity-agent

-- Install .Net Core 2x - https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x

-- Fix for VS2017 Docker-Compose Project breaks build on command line - https://github.com/dotnet/cli/issues/6178

  • mkdir /usr/share/dotnet/sdk/2.0.0/Sdks/Microsoft.Docker.Sdk
  • copy C:\Program Files (x86)\Microsoft Visual Studio\2017{SKU}\MSBuild\Sdks\Microsoft.Docker.Sdk\Sdk to D:\TeamCity\Agent\conf (/usr/share/dotnet/sdk/2.0.0/Sdks)
  • cp -a /data/teamcity_agent/conf/Microsoft.Docker.Sdk/ /usr/share/dotnet/sdk/2.0.0/Sdks/
  • sudo apt install nuget

I have read and followed (unsuccessfully) Error: "error creating aufs mount to" when building dockerfile

So any ideas how I can fix the error "error creating aufs mount to /var/lib/docker/aufs/mnt/ccc81e8c41476a5f72ea23ffc7222ba9b65c47b032a389db9acec26730d1a114-init: invalid argument"

1
A relevant issue in TeamCity tracker (not solved yet): youtrack.jetbrains.com/issue/TW-52939KIR

1 Answers

1
votes

looks like /var/lib/docker should be mounted externally on Windows and TeamCity build agent does not declare it out of the box.

The solution is to pass argument like -v docker_volumes:/var/lib/docker when starting jetbrains/teamcity-agent on Windows