Deffiss / testenvironment-docker

MIT License
117 stars 30 forks source link

Default `Domainname` params for container cause error in docker 19 with userns-remap enable #45

Closed leomao10 closed 3 years ago

leomao10 commented 3 years ago

Hi There,

This is Leo from BitBucket Pipeline 👋

Recently, we upgrade our docker version to 19 and receive bugs reported from our users who have their integration tests failed because of following error:

Error Message:
   Docker.DotNet.DockerApiException : Docker API responded with status code=BadRequest, response={"message":"OCI runtime create failed: container_linux.go:349: starting container process caused \"process_linux.go:449: container init caused \\\"write sysctl key kernel.domainname: open /proc/sys/kernel/domainname: permission denied\\\"\": unknown"}

We did a bit of research for the error, and found that it is because in docker 19 introduce a new change which would lead to the error mentioned above when:

  1. docker-damon has config with 'userns-remap' = 'default'
  2. starting a container with docker run -ti --domainname my.domain some-image

You can find more details in here.

Whereas in testenvironment-docker, we found that it set the container domain name with container name by default: https://github.com/Deffiss/testenvironment-docker/blob/c435fa665ff1bcbce2c63b31d13e1335ae705c88/src/TestEnvironment.Docker/Container.cs#L149-L161

Wondering if testenvironment-docker can provide a way to override the Domainname option, then we can enable docker 19 for those users with minimum changes for their integration tests.

Deffiss commented 3 years ago

Thanks for this deep research, we will try to sort out this issue

Deffiss commented 3 years ago

@leomao10 new version containing the fix has been published. Let us know if it works.

leomao10 commented 3 years ago

Hey @Deffiss Thanks for fixing it so quick, I will let our user know about it 👍

romansp commented 3 years ago

Hey, this bitbucket user is probably us! I originally reported it to Bitbucket support on Nov 10 and their team was very helpful to solve it for us and temporarily whitelisted our repository to use older version of docker.

Very happy to see that it was reported and already fixed here. I just tried running our pipeline on a forked repository with an updated nuget package and appears to work correctly now.

Thanks @leomao10 and @Deffiss.