-
-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bitbucket pipelines throws an error - authorization denied by plugin pipelines: --mounts is not allowed #492
Comments
If your Docker host can't access the domain socket (or IPC socket)
|
Thanks @HofmeisterAn . This worked in bitbucket pipelines. But, seems to fail in Jenkins with this:
Could this be a case for using |
On the above: it's not specific to Jenkins. This is the same error if I run via Docker locally. |
I need more information. Can you add your builder configuration and at least the full stack trace? |
Yup, sure. Here's the config code:
The class
|
Anyway, the console output I have from docker is this (which may not be super helpful):
|
You never create the network. You just build its configuration. Create it first, like: testcontainers-dotnet/tests/Testcontainers.Tests/Fixtures/Containers/Unix/NetworkFixture.cs Line 20 in 124f007
This examples uses a volume, but creating one is equal to a network: #438 |
Yeah, apologies for that. I had recently added that. If that line is removed, the same issue pops up anyway. |
I suppose the problem here is that Testcontainers is running in a docker container within the outer docker container that Jenkins runs in. I could try your bridge network example. |
Hey, just ran into this as well yesterday. I wonder if it would make sense to support the I know it is possible to change the setting in code, but for our use case I think it makes sense to enable Ryuk locally, and only disable it in our pipelines. Unless of course that could have adverse side effects with some clean up features of testcontainers. Currently, our workaround involves a base test fixture that looks for the |
@FaredoonIrani It's looks like Testcontainers can't connect to the Docker endpoint. Where is your Docker endpoint? Is the Docker service running? I did two tests with a Sibling containerenv
_=/usr/bin/env
COPY_REFERENCE_FILE_LOG=/var/jenkins_home/copy_reference_file.log
DEBIAN_FRONTEND=noninteractive
HOME=/root
HOSTNAME=fc5248e6aa28
JAVA_HOME=/opt/java/openjdk
JENKINS_HOME=/var/jenkins_home
JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
JENKINS_SLAVE_AGENT_PORT=50000
JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
JENKINS_UC=https://updates.jenkins.io
JENKINS_VERSION=2.356
LANG=C.UTF-8
PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/workdir
REF=/usr/share/jenkins/ref
SHLVL=1
TERM=xterm
df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 357768 357768 0 100% /usr/bin/docker
/dev/sdc 263174212 23147820 226588236 10% /var/jenkins_home
C:\ 494465020 198242160 296222860 41% /workdir
none 6382388 16 6382372 1% /run/docker.sock
overlay 263174212 23147820 226588236 10% /
shm 65536 0 65536 0% /dev/shm
tmpfs 65536 0 65536 0% /dev
tmpfs 6382388 0 6382388 0% /proc/acpi
tmpfs 6382388 0 6382388 0% /sys/firmware
tmpfs 6382388 0 6382388 0% /sys/fs/cgroup
docker context ls
NAME TYPE DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * moby Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm
dotnet test --logger "console;verbosity=detailed" Testcontainers.Tests.csproj
Determining projects to restore...
Restored /workdir/Testcontainers.Tests.csproj (in 9.55 sec).
Testcontainers.Tests -> /workdir/bin/Debug/net6.0/Testcontainers.Tests.dll
Test run for /workdir/bin/Debug/net6.0/Testcontainers.Tests.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.2.0 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
/workdir/bin/Debug/net6.0/Testcontainers.Tests.dll
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.3+1b45f5407b (64-bit .NET 6.0.6)
[xUnit.net 00:00:00.57] Discovering: Testcontainers.Tests
[xUnit.net 00:00:00.61] Discovered: Testcontainers.Tests
[xUnit.net 00:00:00.61] Starting: Testcontainers.Tests
[xUnit.net 00:00:05.68] Finished: Testcontainers.Tests
Passed Testcontainers.Tests.Sample.PingContainer [16 ms]
Standard Output Messages:
Docker container f56f77d80aaeb49fd398d83273413fd4996d33091358caa69208771feff9c485 created
Start Docker container f56f77d80aaeb49fd398d83273413fd4996d33091358caa69208771feff9c485
Test Run Successful.
Total tests: 1
Passed: 1
Total time: 6.2538 Seconds DinDenv
_=/usr/bin/env
COPY_REFERENCE_FILE_LOG=/var/jenkins_home/copy_reference_file.log
DEBIAN_FRONTEND=noninteractive
HOME=/root
HOSTNAME=e1f8e1058784
JAVA_HOME=/opt/java/openjdk
JENKINS_HOME=/var/jenkins_home
JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
JENKINS_SLAVE_AGENT_PORT=50000
JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
JENKINS_UC=https://updates.jenkins.io
JENKINS_VERSION=2.356
LANG=C.UTF-8
PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/workdir
REF=/usr/share/jenkins/ref
SHLVL=1
TERM=xterm
df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdc 263174212 23147816 226588240 10% /var/jenkins_home
C:\ 494465020 198319868 296145152 41% /workdir
overlay 263174212 23147816 226588240 10% /
shm 65536 0 65536 0% /dev/shm
tmpfs 65536 0 65536 0% /dev
tmpfs 6382388 0 6382388 0% /sys/fs/cgroup
docker context ls
NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm
dotnet test --logger "console;verbosity=detailed" Testcontainers.Tests.csproj
Determining projects to restore...
All projects are up-to-date for restore.
Testcontainers.Tests -> /workdir/bin/Debug/net6.0/Testcontainers.Tests.dll
Test run for /workdir/bin/Debug/net6.0/Testcontainers.Tests.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.2.0 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
/workdir/bin/Debug/net6.0/Testcontainers.Tests.dll
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.3+1b45f5407b (64-bit .NET 6.0.6)
[xUnit.net 00:00:00.56] Discovering: Testcontainers.Tests
[xUnit.net 00:00:00.59] Discovered: Testcontainers.Tests
[xUnit.net 00:00:00.59] Starting: Testcontainers.Tests
[xUnit.net 00:00:02.19] Finished: Testcontainers.Tests
Passed Testcontainers.Tests.Sample.PingContainer [11 ms]
Standard Output Messages:
Docker container 559e50f5d1bc08ed721629e9c31490354e61cbacaf9305a412cd1ddddd0d84d4 created
Start Docker container 559e50f5d1bc08ed721629e9c31490354e61cbacaf9305a412cd1ddddd0d84d4
Test Run Successful.
Total tests: 1
Passed: 1
Total time: 2.8233 Seconds
OC that make sense. With that, I'd like to support the
I would keep it enabled in the pipeline. Anyway, all you need is |
@HofmeisterAn Thanks for this. I will try to reply with some info soon. |
@HofmeisterAn It was my understanding, based on the issue reported here, that using Ryuk in BitBucket pipelines in not supported if it tries to mount the domain socket for Docker. After all, in BitBucket pipelines the docker daemon is accessible only via a TCP endpoint. That is why we have disabled Ryuk permanently in our pipelines on BitBucket. I just want to make sure that there is not a better alternative that we can try to pursue. And yes, we are doing something along the lines of the code you posted, albeit not as a one-liner 😉 |
@HofmeisterAn I don't know about the Docker host locally, let alone the actual Jenkins pipeline. If you have an idea about doing some console logs to get some info, I'll be glad to do that. In the meantime, I tried to replicate my repo structure (see attached). Ran a simple |
@Xitric I meant not in general, but yes, you're right. It won't work with Bitbucket. Sorry for the misconception. @FaredoonIrani Your example can't work. Your Docker image or container does not contain Docker (access to a daemon). It's not mounted nor installed. That's what I'm mentioning above. Testcontainers can't connect to the Docker endpoint (probably it's missing in Jenkins too). Either mount the socket or add Docker to the image:
This is the Dockerfile that I'm using in the example above (WSL2): FROM curlimages/curl:7.83.1 AS curl
RUN echo "Download dependencies..." \
&& curl https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -o /tmp/packages-microsoft-prod.deb \
&& curl https://get.docker.com -o /tmp/get-docker.sh
FROM jenkins/jenkins:2.356
# Don't do this. This is just a multi-stage test.
COPY --from=curl /tmp/* /tmp
USER root
ENV DEBIAN_FRONTEND=noninteractive
RUN echo "Install dependencies..." \
&& echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes \
&& dpkg -i /tmp/packages-microsoft-prod.deb \
&& apt update \
&& apt upgrade \
&& apt install --no-install-recommends \
apt-transport-https \
dotnet-sdk-6.0 \
&& sh /tmp/get-docker.sh \
&& touch /etc/fstab \
&& update-alternatives --set iptables /usr/sbin/iptables-legacy \
&& update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /workdir
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["echo -e \"127.0.0.254\thost.docker.internal\" >> /etc/hosts && service docker start && dotnet test --logger \"console;verbosity=detailed\" Testcontainers.Tests.csproj"] docker build --tag dind-example:0.1.0 .
docker run -it -v $(pwd):/workdir --privileged --rm dind-example:0.1.0 I hope this helps. Otherwise, you need to do some research and study how to set up Docker (especially inside a container). |
@HofmeisterAn Thanks very much. Yes, work needs to be done on my side - apologies for the display of dumbness here. |
No worries. It’s not trivial. You can also ask on Slack if you need help to set-up Docker. |
Thanks @HofmeisterAn. As a followup, just FYI: the So, surprise - no docker. I used Thanks, as always. |
Hi,
Getting this in bitbucket pipelines:
I have tried your suggestion with
WithDockerEndpoint()
in a related issue, but it doesn't fix this.The java testcontainers package seems to have addressed this by providing TESTCONTAINERS_RYUK_DISABLED:
testcontainers/testcontainers-java#700
The text was updated successfully, but these errors were encountered: