Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Bitbucket self hosted runner autostart



I have followed guide how to start self hosted bitbucket runner here:

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>

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.

1 answer

1 accepted

0 votes
Answer accepted
Patrik S Atlassian Team Nov 24, 2021

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 :




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 :

  • If you are creating a new runner container, you can edit the docker command we provide and add the --restart option
docker container run -it --restart=always -v [.....] --name runner-<masked>
  • If you already have the runner container created, you can update it's restart policy using the command:
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

Ajay _view26_ Community Leader Nov 25, 2021

Interesting usecase!

Like Patrik S likes this

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events