Deploying Sourcegraph executors using Docker Compose
This feature is in beta and might change in the future.
A docker-compose file is provided to deploy executors standalone, or alongside your existing Sourcegraph deployment.

How it works
The executor service itself runs in a Docker container and polls Sourcegraph for work. After dequeuing a job, it clones the target repository into a workspace and uses the Docker daemon to run each job step sequentially in another container. Batch Changes jobs that do not use native execution invoke src; code navigation and native Batch Changes jobs invoke Docker directly. Logs and the final job status are streamed back to Sourcegraph.
On this page
Requirements
Privileged containers are required to run executors in docker-compose. This is because executors require access to the docker daemon running on the host.
Deployment
Prerequisites
- Install Docker Compose on the server
- Minimum Docker v20.10.0 and Docker Compose v1.29.0
- Docker Swarm mode is not supported
- Clone the deploy-sourcegraph-docker repository and check out the tag for your Sourcegraph version, such as
v7.5.0
Configure the executor with an override file
Put your executor configuration in an override file instead of editing executor.docker-compose.yaml. The release tag you check out sets the executor image version, so an override file that leaves out image keeps your settings through upgrades without merge conflicts. See What is an override file?.
Set the environment variables the executor needs in the override file. Your override file only needs the values you change; Docker Compose merges them into the executor service from the base file.
On the same machine as Sourcegraph
Add an executor service to the docker-compose.override.yaml file in the docker-compose directory, next to your other overrides:
YAML# docker-compose/docker-compose.override.yaml services: # ...your other Sourcegraph overrides executor: environment: # Must match `executors.accessToken` in site configuration - EXECUTOR_FRONTEND_PASSWORD=<your executors.accessToken> - EXECUTOR_QUEUE_NAMES=batches,codeintel
The base file sets EXECUTOR_FRONTEND_URL to the frontend container, http://sourcegraph-frontend-0:3080, which works on the same machine.
Start Sourcegraph and the executor with the base file, the executor file, and your override file, in that order, from the docker-compose directory:
BASHdocker compose \ -f docker-compose.yaml \ -f executors/executor.docker-compose.yaml \ -f docker-compose.override.yaml \ up -d --remove-orphans
Once your override file configures the executor service, pass all three
files to every docker compose command. Without
executors/executor.docker-compose.yaml, Docker Compose fails with
service "executor" has neither an image nor a build context specified.
On a standalone machine
Create an override file in the docker-compose/executors directory. It also defines the sourcegraph network that the executor service joins:
YAML# docker-compose/executors/executor.docker-compose.override.yaml services: executor: environment: - EXECUTOR_FRONTEND_URL=https://sourcegraph.example.com # Must match `executors.accessToken` in site configuration - EXECUTOR_FRONTEND_PASSWORD=<your executors.accessToken> - EXECUTOR_QUEUE_NAMES=batches,codeintel networks: sourcegraph:
Start the executor from the docker-compose/executors directory:
BASHdocker compose \ -f executor.docker-compose.yaml \ -f executor.docker-compose.override.yaml \ up -d --remove-orphans
Upgrading executors
Check the changelog for any executor-related breaking changes or new features.
-
Check out the tag for the target version in your
deploy-sourcegraph-dockerclone:BASHcd deploy-sourcegraph-docker git fetch git checkout v<target version>The executor image comes from
executor.docker-compose.yamlat that tag. If your override file setsimagefor theexecutorservice, remove it so that the tag's image is used. -
Recreate the executor container by running the same
docker compose up -d --remove-orphanscommand you deployed with, including your override file. Docker Compose pulls the new image and recreates the executor container. The executor briefly disconnects during the restart. -
Verify the new container is running with the expected image:
BASHdocker ps --filter name=executor --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}' -
Confirm the executor is online and reporting the expected version under Administration > Executors > Instances.
Related configuration
Note
Executors deployed via Docker Compose do not use Firecracker, meaning they require privileged access to the Docker daemon running on the host.
If you have security concerns, consider deploying via terraform or installing the binary directly.