Install Sourcegraph with Docker Compose

If you need scalability and high-availability beyond what a single-node Docker Compose can offer, use the Kubernetes cluster deployment option instead.

If you want to migrate from the single-container server (sourcegraph/server) to the Docker Compose deployment, refer to this migration guide.

If you want to backup and/or restore your Docker Compose deployment, refer to this backup and restore guide

Requirements

  • Sourcegraph Enterprise license. You can run through these instructions without one, but you must obtain a license for instances of more than 10 users.
  • Docker Compose.
  • A dedicated host with for your deployment.
    • Use the resource estimator to ensure you provision enough capacity
    • Sourcegraph requires SSD backed storage.

Storage

The Sourcegraph Docker Compose definition uses Docker volumes to store its data. These volumes are stored at /var/lib/docker/volumes by default on Linux.

Note About Windows Installation

The Docker Compose installation requires a minimum of 8 CPU cores (logical) on the host machine in order to complete successfully. If using the Docker for Windows app, the default CPU count is limited to 2 which will result in errors during installation. You can go into the Docker app Settings->Resources window to increase the CPU count to > 8 to resolve this issue.

Steps

It takes less than 5 minutes to run and install Sourcegraph using Docker Compose:

# 🚨 The master branch tracks development. Use the branch of this repository corresponding to the version of Sourcegraph you wish to deploy, e.g. git checkout v3.24.1

git clone https://github.com/sourcegraph/deploy-sourcegraph-docker
cd deploy-sourcegraph-docker/docker-compose
export SOURCEGRAPH_VERSION="v3.30.0"
git checkout $SOURCEGRAPH_VERSION
docker-compose up -d

Once the server is ready (the sourcegraph-frontend-0 service is healthy when running docker ps), navigate to the hostname or IP address on port 80. Create the admin account, then you’ll be guided through setting up Sourcegraph for code searching and navigation.

For next steps and further configuration options, visit the site administration documentation.

Cloud installation guides

Cloud specific Sourcegraph installation guides for AWS, Google Cloud and Digital Ocean.