There is a new version of this tutorial available for Ubuntu 22.04 (Jammy Jellyfish).

How to Install Sentry Error Tracking System with Docker on Ubuntu 18.04 LTS

This tutorial exists for these OS versions

On this page

  1. Requirements
  2. Getting Started
  3. Install Docker CE
  4. Install Sentry

Sentry is a free and open-source error tracking application that can be used to identify issues in real-time. In this tutorial, we will explain how to install Sentry with Docker on Ubuntu 18.04 server.

Requirements

  • A server running Ubuntu 18.04 with 4 GB of RAM.
  • A root password is configured on your server.

Getting Started

Before starting, it is recommended to update your system with the latest version. You can do it with the following command:

apt-get update -y
apt-get upgrade -y

Once the system is updated, restart it to apply all the changes.

Install Docker CE

Next, you will need to install the latest version of Docker CE on your system. By default, the latest version of Docker is not available in the Ubuntu 18.04 default repository. So you will need to add the repository for that.

First, install the required packages with the following command:

apt-get install curl git build-essential apt-transport-https ca-certificates curl software-properties-common -y

Next, download and add the GPG key with the following command:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -

Next, add the Docker CE repository with the following command:

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"

Next, update the repository and install Docker CE with the following command:

apt-get update -y
apt-get install docker-ce -y

Once the Docker has been installed, you can check the status of Docker with the following command:

systemctl status docker

You should see the following output:

? docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-07-03 12:34:40 UTC; 22s ago
     Docs: https://docs.docker.com
 Main PID: 4683 (dockerd)
    Tasks: 8
   CGroup: /system.slice/docker.service
           ??4683 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Jul 03 12:34:37 ubuntu1804 dockerd[4683]: time="2019-07-03T12:34:37.685945390Z" level=warning msg="Your kernel does not support swap memory lim
Jul 03 12:34:37 ubuntu1804 dockerd[4683]: time="2019-07-03T12:34:37.686904854Z" level=warning msg="Your kernel does not support cgroup rt perio
Jul 03 12:34:37 ubuntu1804 dockerd[4683]: time="2019-07-03T12:34:37.687422213Z" level=warning msg="Your kernel does not support cgroup rt runti
Jul 03 12:34:37 ubuntu1804 dockerd[4683]: time="2019-07-03T12:34:37.697386605Z" level=info msg="Loading containers: start."
Jul 03 12:34:38 ubuntu1804 dockerd[4683]: time="2019-07-03T12:34:38.896641657Z" level=info msg="Default bridge (docker0) is assigned with an IP
Jul 03 12:34:39 ubuntu1804 dockerd[4683]: time="2019-07-03T12:34:39.508555810Z" level=info msg="Loading containers: done."
Jul 03 12:34:39 ubuntu1804 dockerd[4683]: time="2019-07-03T12:34:39.939899550Z" level=info msg="Docker daemon" commit=2d0083d graphdriver(s)=ov
Jul 03 12:34:39 ubuntu1804 dockerd[4683]: time="2019-07-03T12:34:39.947534196Z" level=info msg="Daemon has completed initialization"
Jul 03 12:34:40 ubuntu1804 systemd[1]: Started Docker Application Container Engine.
Jul 03 12:34:40 ubuntu1804 dockerd[4683]: time="2019-07-03T12:34:40.230411944Z" level=info msg="API listen on /var/run/docker.sock"

Install Sentry

First, you will need to download the latest version of sentry from the Github repository. You can download it with the following command:

git clone https://github.com/getsentry/onpremise

Once the download has been completed, you should see the following output:

Cloning into 'onpremise'...
remote: Enumerating objects: 13, done.
remote: Counting objects: 100% (13/13), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 228 (delta 3), reused 6 (delta 2), pack-reused 215
Receiving objects: 100% (228/228), 55.14 KiB | 275.00 KiB/s, done.
Resolving deltas: 100% (106/106), done.

Next, build the local custom image with the following command:

cd ~/onpremise
make build

Next, you will need to create a sentry service script. You can create it with the following command:

nano sentry_services.sh

Add the following lines:

#! /bin/bash
clear
docker run --detach --name sentry-redis redis:3.2-alpine
docker run --detach  --name sentry-postgres --env POSTGRES_PASSWORD=secret --env POSTGRES_USER=sentry postgres:9.5
docker run  --detach  --name sentry-smtp tianon/exim4
docker run --rm sentry-onpremise --help
docker run --rm sentry-onpremise config generate-secret-key

Save and close the file, when you are finished. Then, run the script with the following command:

. sentry_services.sh

You should see the following output:

0kvhow&i+k#rjkkc0wvo*n=45=uuua8)51li8)cdjuld6e(2wa

Next, you will need to store the above key in SENTRY_SECRET_KEY variable. You can do this with the following command:

echo 'export SENTRY_SECRET_KEY="0kvhow&i+k#rjkkc0wvo*n=45=uuua8)51li8)cdjuld6e(2wa"' >> ~/.bashrc
source ~/.bashrc

Next, start the migration process with the following command:

docker run --link sentry-redis:redis --link sentry-postgres:postgres --link sentry-smtp:smtp --env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} --rm -it sentry-onpremise upgrade

Once the migration process has been completed successfully, start the Sentry app with the following command:

docker run --detach --name sentry-web-01 --publish 9000:9000 --link sentry-redis:redis --link sentry-postgres:postgres --link sentry-smtp:smtp --env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} sentry-onpremise run web

Next, start the background workers with the following command:

docker run --detach --name sentry-worker-01 --link sentry-redis:redis --link sentry-postgres:postgres --link sentry-smtp:smtp --env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} sentry-onpremise run worker

Next, start the cron process with the following command:

docker run --detach --name sentry-cron --link sentry-redis:redis --link sentry-postgres:postgres --link sentry-smtp:smtp --env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} sentry-onpremise run cron

Sentry is now configured and listens on port 9000. You can access Sentry web interface by visiting the URL http://yourserverip:9000.

Congratulations! you have successfully installed and configured Sentry with Docker on Ubuntu 18.04 server.

Share this page:

5 Comment(s)