Home > Software > How to Deploy Kimai Time Tracking with Docker Compose

How to Deploy Kimai Time Tracking with Docker Compose

Anastasios Antoniadis

Learn to deploy Kimai time tracking software using Docker Compose with our step-by-step guide, including a detailed Docker Compose example and Nginx configuration for a quick and efficient setup.

Docker (1)

Kimai is a free, open-source time-tracking software that allows freelancers, developers, and teams to track their working hours across various projects and tasks. Deploying Kimai with Docker Compose simplifies the process, making it accessible even to those with minimal Docker experience. This article will walk you through the steps to set up Kimai using Docker Compose, ensuring you have a powerful time tracking system that is up and running quickly.


Before you start, ensure Docker and Docker Compose are installed on your system. Docker Compose allows you to easily define and run multi-container Docker applications. With a YAML file, you can configure your application’s services, networks, and volumes and then start everything with a single command.

Step 1: Create a Docker Compose File

To begin, create a docker-compose.yml file in a new directory. This file will define the services, volumes, and configurations to run Kimai. Below is an example Docker Compose file tailored for Kimai:

version: '3.7'

    image: kimai/kimai2:fpm-alpine-1.14
      - APP_ENV=prod
      - DATABASE_URL=mysql://kimaiuser:kimaipassword@database/kimai
      - public:/opt/kimai/public
      - var:/opt/kimai/var
      - database

    image: mysql:5.7
      - MYSQL_DATABASE=kimai
      - MYSQL_USER=kimaiuser
      - MYSQL_PASSWORD=kimaipassword
      - MYSQL_ROOT_PASSWORD=rootpassword
      - db:/var/lib/mysql

    image: nginx:alpine
      - "8001:80"
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - public:/var/www/public:ro
      - kimai


Explanation of the Docker Compose File

  • Kimai Service: Uses the official Kimai image. The environment variables APP_ENV and DATABASE_URL are used to configure Kimai. Volumes are mounted to persist data.
  • Database Service: Uses MySQL 5.7 image, with environment variables to set up the database for Kimai.
  • Nginx Service: Serves as the web server for Kimai. The custom nginx.conf file needs to be created to configure Nginx properly. Port 8001 is exposed for web access.

Step 2: Create the Nginx Configuration

For Nginx to serve the Kimai application correctly, you must provide a configuration file. Create a file named nginx.conf in the same directory as your docker-compose.yml with the following configuration:

worker_processes 1;

events {
    worker_connections 1024;

http {
    server {
        listen 80;
        server_name localhost;

        root /var/www/public;
        index index.php index.html;

        location / {
            try_files $uri /index.php$is_args$args;

        location ~ ^/index\.php(/|$) {
            fastcgi_pass kimai:9000;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $document_root;

        location ~ \.php$ {
            return 404;

This configuration directs Nginx to serve the Kimai application and handle PHP files correctly by forwarding them to the Kimai service.

Step 3: Launch Your Kimai Instance

With the docker-compose.yml and nginx.conf files ready, launch your Kimai instance by running the following command in the directory containing your Docker Compose file:

This command starts all the defined services in detached mode. Your Kimai instance will be accessible at http://localhost:8001.

docker-compose up -d


Deploying Kimai with Docker Compose offers a streamlined and efficient approach to setting up a robust time-tracking system. Following the steps outlined in this guide, you can quickly get Kimai up and running, ready to track your projects and work hours. Docker Compose simplifies the deployment process and ensures that your Kimai instance is easily maintainable and scalable. Whether you’re a freelancer, part of an agency, or managing a team, Kimai provides the features to stay on top of your time management needs.

Anastasios Antoniadis
Follow me
0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x