Docker Environment Variable update

dcassidy 20 hours ago

Hi

I have been running a Traccar server on a AWS Ubuntu instance for a number of years without any issues. I have been looking at creating a new server using Docker. I have no knowledge of Docker. I followed one of the guides:

#Install Docker Engine with the Compose plugin 
curl -fsSL https://get.docker.com | sh
#Disable the Docker userland proxy so the large port range below doesn't spawn a process per port
echo '{"userland-proxy": false}' > /etc/docker/daemon.json && systemctl restart docker
#Create directories for persistent data and logs
mkdir -p /opt/traccar/data /opt/traccar/logs
#Download the official Docker Compose file that runs Traccar together with a MySQL database
curl -o /opt/traccar/compose.yaml https://raw.githubusercontent.com/traccar/traccar/master/docker/compose/traccar-mysql.yaml
#Start Traccar
cd /opt/traccar && docker compose up -d

The Traccar server is working fine. I have tried to add an environmental variable (SERVER_TIMEOUT: "180") to the compose.yaml file.
opt/traccar/compose.yaml

 environment:
      CONFIG_USE_ENVIRONMENT_VARIABLES: "yes"      DATABASE_DRIVER: com.mysql.cj.jdbc.Driver
      DATABASE_URL: >-
        jdbc:mysql://database:3306/traccar
        ?zeroDateTimeBehavior=round
        &serverTimezone=UTC
        &allowPublicKeyRetrieval=true
        &useSSL=false
        &allowMultiQueries=true
        &autoReconnect=true
        &useUnicode=yes
        &characterEncoding=UTF-8
        &sessionVariables=sql_mode=''
      DATABASE_USER: traccar
      DATABASE_PASSWORD: traccar
      SERVER_TIMEOUT: "180"

When I run docker compose up -d. It wipes my login (have to re-register) and device data.

I am clearly doing something wrong.

Please can someone help.

Thanks

Anton Tananaev 20 hours ago

As long as you have something like this, your data should be safe on restarts:

    volumes:
      - /opt/traccar/data:/var/lib/mysql
dcassidy 58 minutes ago

Thanks for the reply Anton. I will check this.