Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bitbucket self hosted runner autostart

Edited

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.

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 :

Flag

Description

no

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.

unless-stopped

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> docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner:1
  • 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
TAGS
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

111 views 2 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you