Start Building for Free

CircleCI Self-hosted Runner Installation on Linux

2 days ago3 min read
Server v4.x
Server v3.x
On This Page

This page describes how to install CircleCI self-hosted runner on Linux.

Download the launch agent script

Save the script file to an easily accessible location. From that location, install the launch agent binary for your target platform, either x86_64, or ARM64:

curl --output ./
chmod +x ./
# For Linux x86_64:
export platform=linux/amd64 && sh ./
# For Linux ARM64:
export platform=linux/arm64 && sh ./

After successful installation, the file can be deleted.

Create the circleci user and working directory

These will be used when executing the task agent. These commands must be run as a user with permissions to create other users (e.g. root). For information about GECOS, see the wiki page.


id -u circleci &>/dev/null || sudo adduser --disabled-password --gecos GECOS circleci


id -u circleci &>/dev/null || sudo adduser -c GECOS circleci

Create the working directory and set permissions

sudo mkdir -p /var/opt/circleci
sudo chmod 0750 /var/opt/circleci
sudo chown -R circleci /var/opt/circleci /opt/circleci/circleci-launch-agent

Consider running the following additional command if you would like to use certified orbs, without errors, that work on Cloud on your self-hosted runner. Note that this enables code to execute root commands on your machine, and changes to the system may persist after the job is run.

echo "circleci ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers

Create the CircleCI self-hosted runner configuration

Create a launch-agent-config.yaml file with a path of /etc/opt/circleci/launch-agent-config.yaml, owned by circleci, with permissions 600. Use the following commands:

sudo mkdir -p /etc/opt/circleci && sudo touch /etc/opt/circleci/launch-agent-config.yaml
sudo chown circleci: /etc/opt/circleci/launch-agent-config.yaml
sudo chmod 600 /etc/opt/circleci/launch-agent-config.yaml

Copy the following to the new /etc/opt/circleci/launch-agent-config.yaml file:

  auth_token: AUTH_TOKEN
  # On server, set url to the hostname of your server installation. For example,
  # url:

  working_directory: /var/opt/circleci/workdir
  cleanup_working_directory: true
  • Replace AUTH_TOKEN with the resource class token created in the set up process.

  • Replace RUNNER_NAME with the name you would like for your self-hosted runner. RUNNER_NAME is unique to the the machine that is installing the runner. RUNNER_NAME can be any value you would like, and it does not need to include any part of your namespace or resource class name.

Configure SELinux policy (RHEL 8)

An SELinux policy is required for self-hosted runner to accept and launch jobs on RHEL 8 systems (earlier versions of RHEL are unsupported). Note that this policy does not add any permissions to the ones that may be required by individual jobs on this self-hosted runner install.

Create directory /etc/opt/circleci/policy and generate the initial policy module:

sudo mkdir -p /etc/opt/circleci/policy
# Install sepolicy and rpmbuild if you haven't already
sudo yum install -y policycoreutils-devel rpm-build
sudo sepolicy generate --path /etc/opt/circleci/policy --init /opt/circleci/circleci-launch-agent

Download the following type enforcing file circleci_launch_agent.te and install the policy:

sudo curl --output /etc/opt/circleci/policy/circleci_launch_agent.te
sudo /etc/opt/circleci/policy/

Start launch agent

You can now start launch agent as follows:

sudo /opt/circleci/circleci-launch-agent --config /etc/opt/circleci/launch-agent-config.yaml

You can also optionally run launch agent as a systemd service.

Referencing your self-hosted runner on a job

After setting up your self-hosted runner, you will need to reference it on a job by setting some fields in your .circleci/config.yml file. The fields you must set for a specific job to run using your self-hosted runners are:

  • machine: true

  • resource_class: your-namespace/your-resource

Here is a simple example of how you could set up a job:

version: 2.1
      - runner
    machine: true
    resource_class: your-namespace/your-resource
      - run: echo "Hi I'm on Runners!"

The job will then execute using your self-hosted runner when you push the config to your VCS provider.

Enable the systemd unit

You will need to have systemd version 235+ installed for this optional step.

Create /usr/lib/systemd/system/circleci.service owned by root with permissions 755.

sudo touch /usr/lib/systemd/system/circleci.service
sudo chown root: /usr/lib/systemd/system/circleci.service
sudo chmod 755 /usr/lib/systemd/system/circleci.service

You must ensure that TimeoutStopSec is greater than the total amount of time a task will run for, which defaults to 5 hours.

If you want to configure the CircleCI self-hosted runner installation to start on boot, it is important to note that the launch agent will attempt to consume and start jobs as soon as it starts, so it should be configured appropriately before starting. The launch agent may be configured as a service and be managed by systemd with the following scripts:

Description=CircleCI Runner
ExecStart=/opt/circleci/circleci-launch-agent --config /etc/opt/circleci/launch-agent-config.yaml
WantedBy =

Unlike the task agent, which uses the environment of the circleci user, the launch agent will need to have any required environment variables (e.g., proxy settings) explicitly defined in the unit configuration file. These can be set by Environment= or EnvironmentFile=. Please visit the systemd documentation for more information.

You can now enable the service:

sudo systemctl enable circleci.service

Start the service

When the CircleCI self-hosted runner service starts, it will immediately attempt to start running jobs, so it should be fully configured before the first start of the service.

sudo systemctl start circleci.service

Verify the service is running

The system reports a very basic health status through the status field in systemctl. This will report Healthy or Unhealthy based on connectivity to the CircleCI APIs.

You can see the status of the agent by running:

systemctl status circleci.service --no-pager

Which should produce output similar to:

circleci.service - CircleCI Runner
   Loaded: loaded (/var/opt/circleci/circleci.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-05-29 14:33:31 UTC; 18min ago
 Main PID: 5592 (circleci-launch)
   Status: "Healthy"
    Tasks: 8 (limit: 2287)
   CGroup: /system.slice/circleci.service
           └─5592 /opt/circleci/circleci-launch-agent --config /etc/opt/circleci/launch-agent-config.yaml

You can also see the logs for the system by running:

journalctl -u circleci

Help make this document better

This guide, as well as the rest of our docs, are open source and available on GitHub. We welcome your contributions.

Need support?

Our support engineers are available to help with service issues, billing, or account related questions, and can help troubleshoot build configurations. Contact our support engineers by opening a ticket.

You can also visit our support site to find support articles, community forums, and training resources.