Skip to content

Instantly share code, notes, and snippets.

@jjsquady
Last active April 5, 2024 04:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjsquady/59847068b6fc4e86aee6d0322681a00e to your computer and use it in GitHub Desktop.
Save jjsquady/59847068b6fc4e86aee6d0322681a00e to your computer and use it in GitHub Desktop.
Traccar Docker + PostgreSQL

Install Traccar with Docker + PostgreSQL

Create a new folder traccar on your preference.

Create a file named docker-compose.yml into this traccar folder and put the content bellow:

version: '3.9'

services:
  postgres:
    image: postgres
    environment:
      POSTGRES_PASSWORD: '${PGSQL_DB_PASSWORD:-postgres}'
      POSTGRES_DB: 'traccar'
    ports:
      - '${PGSQL_DB_PORT:-5432}:5432'
    volumes:
      - "pgdata:/var/lib/postgresql/data"

  traccar:
    image: traccar/traccar
    hostname: traccar
    ports:
     - "15000-15005:5000-5005"
     - "18082:8082"
    volumes:
     - ./conf/traccar.xml:/opt/traccar/conf/traccar.xml

volumes:
  pgdata:
  

Create a new dir called conf into traccar folder.

Create a new file into conf folder called traccar.xml and put content bellow:

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>

<properties>

    <entry key='config.default'>./conf/default.xml</entry>

    <!--
    This is the main configuration file. All your configuration parameters should be placed in this file.
    Default configuration parameters are located in the "default.xml" file. You should not modify it to avoid issues
    with upgrading to a new version. Parameters in the main config file override values in the default file. Do not
    remove "config.default" parameter from this file unless you know what you are doing.
    For list of available parameters see following page: https://www.traccar.org/configuration-file/
    -->

        <entry key='database.driver'>org.postgresql.Driver</entry>
        <entry key='database.url'>jdbc:postgresql://postgres:5432/traccar</entry>
        <entry key='database.user'>postgres</entry>
        <entry key='database.password'>postgres</entry>

</properties>

Execute: docker compose up -d

That`s it! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment