I have tried and tried but cannot get the Docke image to utilise MySQL. It appears to fail and fall back silently to use the internal DB. Here is my Docker compose file. Please comment if you can see an issue with it:
services:
mysql:
image: mysql:8.0
container_name: traccar-mysql-local
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: traccar
MYSQL_USER: traccar
MYSQL_PASSWORD: 123456
volumes:
- mysql-data:/var/lib/mysql
command: --default-authentication-plugin=mysql_native_password
traccar:
image: traccar/traccar:latest
container_name: traccar-app-local
restart: always
ports:
- "8082:8082"
- "5055:5055"
- "5055:5055/udp"
environment:
DATABASE_URL: "jdbc:mysql://mysql:3306/traccar?allowPublicKeyRetrieval=true&useSSL=false"
DATABASE_USER: "traccar"
DATABASE_PASSWORD: "123456"
DATABASE_DRIVER: "com.mysql.jdbc.Driver"
depends_on:
- mysql
volumes:
mysql-data:
How did you enable Traccar to use env variables?
Dear, you do not need these environment variables here when creating the Traccar container, you must pass them in the traccar.xml configuration file.
This is from the configuration file docs:
"Ii is also possible to use environment variables instead of the configuration file, and these environment variables take precedence over the values in the config file."
You have to set CONFIG_USE_ENVIRONMENT_VARIABLES
to enable environment variables.
Thanks everyone, I got it working. Much appreciated!
Oops, didn’t know it worked that way (need to set CONFIG_USE_ENVIRONMENT_VARIABLES). Live and learn!
I have tried and tried but cannot get the Docke image to utilise MySQL. It appears to fail and fall back silently to use the internal DB. Here is my Docker compose file. Please comment if you can see an issue with it:
services: mysql: image: mysql:8.0 container_name: traccar-mysql-local restart: always environment: MYSQL_ROOT_PASSWORD: 123456 MYSQL_DATABASE: traccar MYSQL_USER: traccar MYSQL_PASSWORD: 123456 volumes: - mysql-data:/var/lib/mysql command: --default-authentication-plugin=mysql_native_password traccar: image: traccar/traccar:latest container_name: traccar-app-local restart: always ports: - "8082:8082" - "5055:5055" - "5055:5055/udp" environment: DATABASE_URL: "jdbc:mysql://mysql:3306/traccar?allowPublicKeyRetrieval=true&useSSL=false" DATABASE_USER: "traccar" DATABASE_PASSWORD: "123456" DATABASE_DRIVER: "com.mysql.jdbc.Driver" depends_on: - mysql volumes: mysql-data: