Install Sourcegraph with Docker


It takes less than a minute to run and install Sourcegraph using Docker:

docker run --publish 7080:7080 --publish 127.0.0.1:3370:3370 --rm --volume ~/.sourcegraph/config:/etc/sourcegraph --volume ~/.sourcegraph/data:/var/opt/sourcegraph sourcegraph/server:3.17.3

Once the server is ready (logo is displayed in the terminal), navigate to the hostname or IP address on port 7080. 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.

File system performance on Docker for Mac

There is a known issue in Docker for Mac that causes slower than expected file system performance on volume mounts, which impacts the performance of search and cloning.

To achieve better performance, you can do any of the following:

  • For better clone performance, clone the repository on your host machine and then add it to Sourcegraph Server.
  • Try adding the :delegated suffix the data volume mount. Learn more.
    --volume ~/.sourcegraph/data:/var/opt/sourcegraph:delegated
    

Testing Sourcegraph on Windows

Sourcegraph can be tested on Windows 10 using roughly the same steps provided above, but data will not be retained after server restarts (this is due to a limitation of Docker on Windows).

  1. Install Docker for Windows
  2. Using a command prompt, follow the same installation steps provided above but remove the --volume arguments. For example by pasting this:
docker run --publish 7080:7080 --publish 127.0.0.1:3370:3370 --rm sourcegraph/server:3.17.3

Low resource environments

To test sourcegraph in a low resource environment you may want to disable some of the observability tools (Prometheus, Grafana and Jaeger).

Add -e DISABLE_OBSERVABILITY=true to your docker run command

Insiders build

To test new development builds of Sourcegraph (triggered by commits to master), change the tag to insiders in the docker run command.

docker run --publish 7080:7080 --rm --volume ~/.sourcegraph/config:/etc/sourcegraph --volume ~/.sourcegraph/data:/var/opt/sourcegraph sourcegraph/server:insiders

To keep this up to date, run docker pull sourcegraph/server:insiders to pull in the latest image, and restart the container to access new changes.

Next steps