I’m working on configuring a Ubuntu 22.04 LTS system to function as a server for a custom app, running in a Docker Compose container.
This is my yaml file:
version: "3.9" services: production: image: customapp:v17.2.5 container_name: customapp restart: unless-stopped tty: true network_mode: "host" volumes: - /production/app-data/production-data:/data - /production/app-data/backupdrv:/data/backupdrv - /production/app-data/certs:/etc/certs/<ssl cert files>
As you can see, a few volumes are linked, one of these is the /backupdrv directory. This is a directory on a USB stick where our app stores and re-stores backups.
The problem I’m running into is that if the USB stick isn’t mounted when the Docker container is started, the backup files aren’t accessible. Makes sense of course, but they remain inaccessible even after you plug in the USB stick post-Docker start.
We will be deploying this server twice, one main unit and a secondary server in case the first one ever breaks down. In order to get the secondary server up and running, our client will need to plug the USB stick with the backup files from one server into the other. This is why we need the Docker container to dynamically pick up when these USB files are available. We don’t want to have to teach our client to manually restart the server in case they need to swap the backup USB stick.
Outside of Docker, I’ve tried to trigger a ‘docker compose restart’ command using a udev rule and while that DOES seem to restart the Docker container, the USB files end up not being connected. The only way the USB files are picked up properly is if I manually run the restart script from a terminal on the server or via SSH.
Does anyone know if there’s a way for Docker to re-initialize (USB) volumes while the container is already running?