Setting up Redmine with Docker

Redmine is one of the major web applications that are used in project management. It is easy to warm up and personalize Redmine due to its support for themes and plugins. In this post, we are going to cover how to install Redmine with Docker. We will use Postgres as our database choice. We will store files of stateful apps in volumes that we will create on our server.


Manual Installation With Docker

Creating a Network

We will start with creating a Docker network for communication between Postgres and Redmine. We are going to apply these commands on a single machine, so we will set up a bridge network:

$ docker network create — driver bridge redmine_network

Creating Volumes

As stated earlier, we will create volumes for stateful services. We need these volumes for keeping the state of services and avoiding automatically removing files when containers are removed:

$ docker volume create postgres-data
$ docker volume create redmine-data

We will tell Docker about which volume belong to which directory when creating containers.

Starting Database

We mentioned that we will install Redmine with Postgres. Now, let’s start Postgres with the network and volume that we created above:

docker container run -d                         \ 
--name postgres \
--network redmine_network \
-v postgres-data:/var/lib/postgresql/data \
--restart always \
-e POSTGRES_PASSWORD='password' \
-e POSTGRES_DB='redmine' \
postgres:latest

Starting Redmine

Finally, we can start Redmine with the database address and credentials that we have just created:

docker container run -d                         \ 
--name redmine \
--network redmine_network \
-p 80:3000 \
--restart always \
-v redmine_data:/usr/src/redmine/files \
-e REDMINE_DB_POSTGRES='postgres' \
-e REDMINE_DB_DATABASE='redmine' \
-e REDMINE_DB_PASSWORD='password' \
redmine:latest

After that, we can open our browser and write the IP address in order to see our installation. Default username and password are set to admin — admin.


Installing With Docker Compose

We could utilize Docker Compose for defining all the above process in a single YAML file. The content of file docker-compose.yml is:

version: '3.1'
services:
postgres:
image: postgres:latest
restart: always
networks:
- redmine
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
- 'POSTGRES_PASSWORD=password'
- 'POSTGRES_DB=redmine'
  redmine:
image: redmine:latest
restart: always
networks:
- redmine
volumes:
- redmine-data:/usr/src/redmine/files
ports:
- 80:3000
environment:
- 'REDMINE_DB_POSTGRES=postgres'
- 'REDMINE_DB_DATABASE=redmine'
- 'REDMINE_DB_PASSWORD=password'
volumes:
postgres-data:
redmine-data:
networks:
redmine:
driver: bridge

After creating this file, the only thing we should do is running this command:

docker-compose up

Conclusion

We have completed an example installation of Redmine with Docker and Docker Compose. We have defined what is needed for a manual installation with pre-built Docker images; afterward, we implemented the same structure with Docker Compose in one single file. Defining all services, networks, and volumes in a single file, creating and destroying all services or some part of them with a single command and the chance of getting logs of all services to a single terminal window is some of the pros of this method. Be sure that you take all necessary precautions when you use these images and methods other than tests.