How to setup sentry with docker How to setup sentry with docker docker docker

How to setup sentry with docker


UPDATE circa version 21

They don't seem to want to build the official image for us any more as per the deprecation notice on Docker Hub. However, good news, in https://develop.sentry.dev/self-hosted/#getting-started

  • They supply an install script
  • There is an official docker-compose included

Seems Kafka and Zookeeper are now required too. Follow the docs to stay up to date.


This is a moving target. I suggest checking https://hub.docker.com/_/sentry/ for updates as their documentation is pretty good.

Circa version 8 you can easily convert those instructions to use docker-compose

docker-compose.yml

version: "2"services:  redis:    image: redis:3.0.7    networks:    - sentry-net  postgres:    image: postgres:9.6.1    environment:    - POSTGRES_USER:sentry    - POSTGRES_PASSWORD:sentry    # volumes:    # - ./data:/var/lib/postgresql/data:rw    networks:    - sentry-net  sentry:    image: sentry:${SENTRY_TAG}    depends_on:    - redis    - postgres    environment:    - SENTRY_REDIS_HOST=redis    - SENTRY_SECRET_KEY=${SECRET}    - SENTRY_POSTGRES_HOST=postgres    ports:    - 9000:9000    networks:    - sentry-net  sentry_celery_beat:    image: sentry:${SENTRY_TAG}    depends_on:    - sentry    environment:    - SENTRY_REDIS_HOST=redis    - SENTRY_SECRET_KEY=${SECRET}    - SENTRY_POSTGRES_HOST=postgres    command: "sentry run cron"    networks:    - sentry-net  sentry_celery_worker:    image: sentry:${SENTRY_TAG}    depends_on:    - sentry    environment:    - SENTRY_REDIS_HOST=redis    - SENTRY_SECRET_KEY=${SECRET}    - SENTRY_POSTGRES_HOST=postgres    command: "sentry run worker"    networks:    - sentry-netnetworks:  sentry-net:

.env

SENTRY_TAG=8.10.0

Run docker run --rm sentry:8.10.0 config generate-secret-key and add the secret

.env updated

SENTRY_TAG=8.10.0SECRET=somelongsecretgeneratedbythetool

First boot:

docker-compose up -d postgresdocker-compose up -d redisdocker-compose run sentry sentry upgrade

Full boot

docker-compose up -d

Debug

docker-compose psdocker-compose logs --tail=10


Take a look at the sentry.conf.py file that is part of the official sentry docker image. It gets a bunch of properties from the environment e.g. SENTRY_DB_NAME, SENTRY_DB_USER. Below is an excerpt from the file.

os.getenv('SENTRY_DB_PASSWORD')or os.getenv('MYSQL_ENV_MYSQL_PASSWORD')or os.getenv('MYSQL_ENV_MYSQL_ROOT_PASSWORD')

So as for your question about how to sepcify database password it must be set in environment variables. You can do this by running:

sudo docker run --name some-sentry --link some-mysql:mysql \    -e SENTRY_DB_USER=XXX                                  \    -e SENTRY_DB_PASSWORD=XXX                              \    -d sentry

As for your issue with the exception you seem to be missing a config file Configuration file does not exist at '/.sentry/sentry.conf.py' That file is copied to /home/user/.sentry/sentry.conf.py inside the container. I am not sure why your sentry install is looking for it at /.sentry/sentry.conf.py. There may be an environment variable or a setting that controls this or this may just be a bug in the container.


This works for me https://github.com/slafs/sentry-docker and we don't have to setup database or others. I will learn more about the configuration in detail later.