How to restart Docker container? #1360
-
I have RA running on 4 RPi's. Their configurations are identical and Ansible updates and restarts them with no problem. But I have one instance of RA running in a Docker container under Ubuntu. Its files are updated correctly, but Ansible doesn't know how to restart the container. I've looked through the docs and it seems it would have to with 'tasks', but the syntax is not clear to me, along with how to isolate such a task to only that box. Can someone point me to a complete example of this in a heterogeneous environment similar to mine? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I may have answer. You can create a service and have that service launch RA on startup. Here is my service file: `[Unit] [Service] [Install] At the top level of the directory where my config directory resides, I created the two scripts referenced for start/stop of the service. `#!/bin/bash docker-compose up` stop_docker.sh: `#!/bin/bash docker-compose down' This seems to be working just fine for me, but any improvement ideas would be greatly appreciated. Hope this helps someone. |
Beta Was this translation helpful? Give feedback.
I may have answer. You can create a service and have that service launch RA on startup. Here is my service file:
`[Unit]
Description=Docker Compose Application Service
Requires=docker.service
After=docker.service
StartLimitIntervalSec=60
[Service]
WorkingDirectory=/home/lorenzot/room-assistant
ExecStart=/home/lorenzot/room-assistant/start_docker.sh
ExecStop=/home/lorenzot/room-assistant/stop_docker.sh
TimeoutStartSec=0
Restart=always
StartLimitBurst=1
User=lorenzot
[Install]
WantedBy=multi-user.target`
At the top level of the directory where my config directory resides, I created the two scripts referenced for start/stop of the service.
These contents of these is:
start_docker.sh:
`#!/bin…