Deploying with Docker
Through Docker, PostHogers can install specific versions of the app while also having it within a containerized environment.
We currently have three types of images:
posthog/posthog:latest- builds the most up-to-date release
posthog/posthog:release-[version number]- builds a specific app version
posthog/posthog:preview- builds a preview image
We recommend using
posthog/posthog:latest, so you have the latest features and security updates!
If you are deploying with Docker on AWS or Digital Ocean, you can check our individual specific tutorials instead of following this generic tutorial:
sudo apt-get install git git clone https://github.com/posthog/posthog.git cd posthog docker-compose up -d
If you're running locally:
- Make sure to add
DEBUG=1as an environment variable - this will prevent an infinite loop of SSL redirects.
- PostHog assumes you want to use SSL and will redirect you to
https://.... To avoid this, set
- With these two recommendations your new
docker-composestatement will look like this:
docker-compose up -d -e DEBUG=1 DISABLE_SECURE_SSL_REDIRECT=1
If you're running your Postgres database elsewhere (i.e. RDS, or a different server) you can edit the docker-compose file and do the following:
- Set the
DATABASE_URLproperty to the location of your database
services -> dband
depends_on: - db
If you would like to run the software locally, you can use a Docker preview. Note that this is not meant for production use.
Paste the following snippet into your terminal:
docker run -t -i --rm --publish 8000:8000 -v postgres:/var/lib/postgresql posthog/posthog:preview
Upgrading Docker depends on how you've deployed PostHog with Docker.
- If you deployed with docker-compose, run
docker-compose pull web
If you've pinned a version, see CHANGELOG.md for the latest version.
PostHog is now using Redis with a worker to process events and other background tasks. If you're getting a
REDIS_URL is required error or you see
Configuration Error in the interface, you'll need to setup a Redis server and run the worker process.
If you're using a docker-compose file, either pull the latest version from
master, or add the following to your docker-compose file:
redis: image: "redis:alpine" container_name: posthog_redis web: ... environment: ... REDIS_URL: "redis://redis:6379/" depends_on: - db - redis links: - db:db - redis:redis
If you last updated PostHog before 3 March 2020 AND you have a lot of events, there is one migration (0027) that might take a long time.
To avoid this, before you migrate, run
python manage.py migrate_elementgroup to pre-migrate elements across.
If you only have a few thousand events, you probably don't need to worry about this.