Skip to content

Latest commit

 

History

History
121 lines (86 loc) · 4.64 KB

install-machine-runner-3-on-docker.adoc

File metadata and controls

121 lines (86 loc) · 4.64 KB
contentTags
platform
Cloud
Server v4.4+

Install machine runner 3 on Docker

This page describes how to install CircleCI’s machine runner 3 with the Docker executor. If you are looking to set up self-hosted runners in a private Kubernetes cluster, visit the Container runner page.

Note

Container runner is the recommended method for self-hosted runner Docker installation. The instructions on this page are for a simple Docker setup using machine runner 3.

Container runner is the recommended approach for running containerized jobs on self-hosted runners. Container runner offers the ability to seamlessly define, publish, and use custom Docker images during job execution, as well as the ability to manage dependencies or libraries through custom Docker images instead of enumerating dependencies as part of steps in the .circleci/config.yml file.

Machine-based approach with Docker

Prerequisites

Resource requirements

The host needs to have Docker installed. Once the runner container is started, the container will immediately attempt to start running jobs. The container will be reused to run more jobs indefinitely until it is stopped.

The number of containers running in parallel on the host is constrained by the host’s available resources and your jobs' performance requirements.

Self-hosted runner terms agreement

1. Create namespace and resource class

2. Create a Dockerfile that extends the machine runner 3 image

Create a Dockerfile.runner.extended file. In this example, Python 3 is installed on top of the base image.

FROM circleci/runner-agent:machine-3
RUN sudo apt-get update; \
    sudo apt-get install --no-install-recommends -y \
        python3

3. Build the Docker image

docker build --file ./Dockerfile.runner.extended .

4. Start the Docker container

Note
The environment variable values are not available to the docker command, so these environment variables are not visible in ps output.
CIRCLECI_RUNNER_NAME=<runner-name> CIRCLECI_RUNNER_API_AUTH_TOKEN=<runner-token> docker run --env CIRCLECI_RUNNER_NAME --env CIRCLECI_RUNNER_API_AUTH_TOKEN --name <container-name> <image-id-from-previous-step>

When starting the Docker container on server, the CIRCLECI_RUNNER_API_URL environment variable will also need to be passed in using the --env flag.

CIRCLECI_RUNNER_NAME=<runner-name> CIRCLECI_RUNNER_API_AUTH_TOKEN=<runner-token> CIRCLECI_RUNNER_API_URL=<server_host_name> docker run --env CIRCLECI_RUNNER_NAME --env CIRCLECI_RUNNER_API_AUTH_TOKEN --env CIRCLECI_RUNNER_API_URL --name <container-name> <image-id-from-previous-step>

When the container starts, it will immediately attempt to start running jobs.

Stopping the Docker container

docker stop <container-name>

Remove the Docker container

In some cases you might need to fully remove a stopped machine runner container from the system, such as when recreating a container using the same name.

docker stop <container-name>; docker rm <container-name>;

Migrating from launch agent

Note
In machine runner 3, the environment variable name prefix has changed from LAUNCH_AGENT_ to CIRCLECI_RUNNER_.

To migrate from launch agent to machine runner 3 on Docker, stop and remove the launch agent containers and replace them with machine runner 3 containers, using the commands described above.