I'm currently running an executable in Docker that has been mounted as a Docker volume in the foreground. The executable (or the service) continuously generates console output and can be interrupted by the Ctrl-C signal. From time to time, I have to update the service executable "manually". To do this, I wrote a sh script that temporarily stops the Docker container, downloads the new executable, unpacks it and restarts the Docker container. Is this a common way for my use case? Or can I update it in the container itself?
Below parts from:
docker-compose.yml
myservice:
image: debian:12
init: true
stop_grace_period: 1m
user: 1000:1000
volumes:
- /home/tobi/myservice/:/myservice/
command: >
bash -c "cd /myservice/ && ./myserviceExec"
labels:
- "traefik.enable=true"
- "traefik.http.routers.myservice.rule=Host(`sub.mydomain.com`)"
- "traefik.http.services.myservice.loadbalancer.server.port=80"
- "traefik.http.routers.myservice.entrypoints=websecure"
- "traefik.http.routers.myservice.tls.certresolver=myresolver"
update_script.sh
#!/bin/sh
docker stop proxy-myservice-1
sleep 5
sh script_backup.sh
sleep 5
wget https://...afile.zip
sleep 5
unzip afile.zip
sleep 5
mv -v myserviceExec myservice/
rm -v afile.zip
sleep 5
docker start proxy-myservice-1
sleep 5
ls -la --color=auto
ls -la --color=auto myservice/
sleep 30
docker logs -t proxy-myservice-1