How do I start a Linux Docker Runner in the background?
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
Once a Linux Docker runner is started, the output/logs of the runner will be printed in the terminal while the runner is running. This prevents the user from using that terminal window to execute any other commands.
Environment
Linux Docker self-hosted runners in Bitbucket Pipelines
Solution
If you have already started the Linux Docker Runner:
You can use the shortcuts Ctrl and p and right after Ctrl and q. This will detach the runner's container, so you can execute other commands in the terminal, and the runner will keep running.
If you want to attach the container's output later on:
Run the command
1
docker ps
Look for the line in the output where the IMAGE is docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner:1, e.g.:
1 2
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 053f3260518e docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner:1 "/bin/sh -c ./entryp…" 4 minutes ago Up 4 minutes runner-0g7312d8-1b57-5772-7e02-f46e5093dd5d
Copy the value of the CONTAINER ID for that line, in the example above it is 053f3260518e
Run the following command, where 053f3260518e should be replaced with the Container ID from the previous step for your runner.
1
docker attach 053f3260518e
If you haven't started the Linux Docker Runner yet:
Run the preconfigured command that starts the runner with the -d argument as well, as follows:
1
docker container run -itd <the rest of the arguments>
You can then use the same steps provided in the section above if you want to attach the container's output and then detach it again.
Was this helpful?