Hello,
I have followed guide how to start self hosted bitbucket runner here: https://support.atlassian.com/bitbucket-cloud/docs/runners/
I now have docker command to start my runner on my server and it works as expected, builds are running.
docker container run -it -v /tmp:/tmp -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/containers:/var/lib/docker/containers:ro -e ACCOUNT_UUID={<masked>} -e REPOSITORY_UUID={<masked>} -e RUNNER_UUID={<masked>} -e RUNTIME_PREREQUISITES_ENABLED=true -e OAUTH_CLIENT_ID=<masked> -e OAUTH_CLIENT_SECRET=<masked> -e WORKING_DIRECTORY=/tmp --name runner-<masked> docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner:1
Now I need to make it headless, so that I would not need to start runner manually using command line every time my server restarts.
Is there any official documentation how to do that?
I know this might me basic docker question, but I would like to know the way how to do it like Atlassian intends.
Hello Karolis,
Welcome to Atlassian Community!
Unfortunately, at this moment there's no official Atlassian documentation on how to auto-start the runner's container after system restart, but you can refer to the official docker documentation about container restarting policies.
Docker provides different restarting policies that will dictate if your containers will be automatically started when they exit or when the docker daemon restarts. Following you have all the current available policies :
Flag |
Description |
---|---|
|
Do not automatically restart the container. (the default) |
on-failure |
Restart the container if it exits due to an error, which manifests as a non-zero exit code. |
always |
Always restart the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted. |
|
Similar to always , except that when the container is stopped (manually or otherwise), it is not restarted even after Docker daemon restarts. |
To setup a restarting policy in a given container you can use the --restart option and provide one of the flags above, accordingly to your use case.
Since you've mentioned you want your containers started after every server restart, I'd suggest using the --restart=always option, by following one of the below suggestions :
docker container run -it --restart=always -v [.....] --name runner-<masked> docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner:1
docker update --restart=always <runner container name>
Please, let me know if you run into any issues trying one of my suggestions above.
Best regards,
Patrik S
Interesting usecase!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.