Run Atlassian Jira and Confluence with PostgreSQL on Docker

Overview of series “How to run Jira and Confluence behind NGINX reverse proxy on Docker”

This will be the first article of a quick start series on how to run Jira and Confluence with PostgreSQL as their database on a single Docker host.

  1. Run Atlassian Jira and Confluence with PostgreSQL on Docker
  2. NGINX as reverse proxy for Jira and Confluence on Docker
  3. Disable external access to PostgreSQL
  4. Enable SSL for NGINX reverse proxy using Let’s Encrypt on Docker

Introdution

In this article we will run Jira and Confluence with PostgreSQL on Docker. It is very easy to do that because Atlassian releases their systems as Docker images on the Docker Hub. One of the biggest benefits of doing that is an easy update process of Jira or Confluence. In the best case this will require 2 simple commands only. Another benefit is that you only have to maintain one operating system for both or in future also additional services.

I had the plan to do that for a long time and then also found the necessary resource for it. Many thanks to Nobuyuki_Mukai for this great article in the Atlassian community: https://community.atlassian.com/t5/Jira-Articles/Running-Atlassian-server-product-on-Docker/ba-p/1209665

Prerequisites

Install Docker

Install Docker by following the official Docker installation documentation:
https://docs.docker.com/install/linux/docker-ce/debian/

DNS configuration

First of all you need a proper DNS configuration. Setup your DNS server to alias the names you want to have for Jira and Confluence to your Docker host.

Setup PostgreSQL as Database for Jira and Confluence

Startup PostgreSQL container

We will startup the official PostgreSQL image from the Docker Hub with the following command. The image tag 10 means that we will use version 10 of PostgreSQL. This is beacuse this is the highest compatible PostgreSQL version for Confluence. Jira currently would support version 11.

docker run -d  -p 5432:5432 \
    --name postgres \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_PASSWORD=mysecretpassword \
    -v postgresData:/var/lib/postgresql/data \
    postgres:10

Startup pgAdmin container

Additionally startup pgAdmin to be able to configure the databases through an user interface (Docs):

docker run -p 5050:80 \
    --name pgadmin \
    -e 'PGADMIN_DEFAULT_EMAIL=postgres' \
    -e 'PGADMIN_DEFAULT_PASSWORD=SuperSecret' \
    -v pgadminData:/pgadmin4 \
    -v pgAdminApplicationData:/var/lib/pgadmin \
    -d dpage/pgadmin4

Connect pgAdmin with PostgreSQL database sever

Now enter YOUR_IP:5050 into a browser. This will open pgAdmin. Login with the credentials you have setup in the environment variables PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD.

pgAdmin start screen

Click onto “Add New Server” in the Quick Links section
Add a “Name” for the connection
In the “Connection” tab configure “Host name / address“, “Username” and “Password” – then click “Save

connect to server in pgAdmin
Configure Name of the connection
connect to server in pgAdmin 2
Configure the connections host name / address, username and password

Create databases for Jira and Confluence

Configuring a PostgreSQL database for Jira is documented by Atlassian here. Read this documentation first. Supported platforms for Jira are documented here. Also read this documentation to ensure system compatibility.

We will create an own user for each database who is owner of it’s own database. Username and database name will be the same to keep it simple. This is more secure than using the postgres system user for databases.

First we will create user and database for Jira:

Right click “Login/Group Roles” -> Create -> Login/Group Role…

create user in pgAdmin

Fill in your users “Name” in General tab

create user in pgAdmin - general

Goto Definition tab enter your new “Password”

create user in pgAdmin - definition

In Privileges tab set “Can login?” to “Yes” and click onto “Save

create user in pgAdmin - privileges

Right click “Databases” -> Create -> Database…

create database in pgAdmin

In “General” tab enter your new database name into field Database and set the Owner of it to your created user

create database in pgAdmin - general

In “Definition” tab set Template to “template0“, Collation and Character type to “C

create database in pgAdmin - definition jira

Now check out these 2 documentations for Confluence:
Supported Platforms
Database Setup for PostgreSQL

Repeat the above steps to also create an user and database for Confluence. If something changed in Atlassians documentations correct it with their changes.

The database configuration for Confluence differs a little bit from Jira. See the below screenshot for correct definition:

create database in pgAdmin - definition confluence
Collation: en_US.utf8

Start Jira and Confluence with PostgreSQL on Docker containers

Start and configure Jira container

We are ready to startup a Jira container now. Atlassian has released an image for it in the Docker Hub. Run the following command to do so:

docker run -d -p 8080:8080 \
    --name jira \
    -e JVM_MINIMUM_MEMORY=2048m \
    -e JVM_MAXIMUM_MEMORY=8192m \
    -v jiraApplicationData:/var/atlassian/application-data/jira \
    atlassian/jira-software:latest

You can connect to your new Jira instance in your browser by navigating to YOUR_IP:8080. Follow the configuration assistant and Jira will be up and running.

Start and configure Confluence container

For Confluence we will use the official image from Atlassian which can be downloaded from the Docker Hub as well. Type this Docker command into your shell to startup Confluence:

docker run -d -p 8090:8090 -p 8091:8091 \
    --name confluence \
    -e JVM_MINIMUM_MEMORY=2048m \
    -e JVM_MAXIMUM_MEMORY=8192m \
    -v confluenceApplicationData:/var/atlassian/application-data/confluence \
    atlassian/confluence-server:latest

After the container is up navigate to YOUR_IP:8090 and follow the Confluence setup assistant.

Conclusion

You have now successfully started Confluence and Jira with PostgreSQL on Docker. The systems are accessible through the ports 8080 and 8090. Next step would be to implement NGINX as a reverse proxy to make both systems availaible by their name on port 80.

NGINX as reverse proxy for Jira and Confluence on Docker

NGINX as reverse proxy for Jira and Confluence on Docker

Leave a Reply