-
-
Notifications
You must be signed in to change notification settings - Fork 3
Docker Management
MrD3y5eL edited this page Jan 12, 2025
·
2 revisions
This guide explains how to manage Docker containers on your Unraid server through Home Assistant.
The Unraid integration provides the following Docker container controls:
- View container status
- Start/Stop containers
- Execute commands within containers
- Monitor container states
Each Docker container appears as a switch entity in Home Assistant:
switch.unraid_docker_[container_name]
Example entities:
switch.unraid_docker_plex
switch.unraid_docker_homeassistant
switch.unraid_docker_nginx
# Using switch entity
service: switch.turn_on
target:
entity_id: switch.unraid_docker_plex
# Using service call
service: unraid.execute_command
data:
entry_id: "1234abcd5678efgh"
command: "docker start plex"
# Using switch entity
service: switch.turn_off
target:
entity_id: switch.unraid_docker_plex
# Using service call
service: unraid.execute_command
data:
entry_id: "1234abcd5678efgh"
command: "docker stop plex"
service: unraid.execute_in_container
data:
entry_id: "1234abcd5678efgh"
container: "plex"
command: "ls -l /config"
detached: false
alias: "Restart Plex When Frozen"
description: "Restart Plex container if it becomes unresponsive"
trigger:
- platform: state
entity_id: binary_sensor.plex_available
to: "off"
for:
minutes: 2
action:
- service: switch.turn_off
target:
entity_id: switch.unraid_docker_plex
- delay:
seconds: 30
- service: switch.turn_on
target:
entity_id: switch.unraid_docker_plex
alias: "Update Docker Containers"
trigger:
- platform: time
at: "03:00:00"
condition:
- condition: time
weekday:
- mon
action:
- service: unraid.execute_command
data:
entry_id: "1234abcd5678efgh"
command: "docker container ls -q | xargs -r docker update"
alias: "Docker Maintenance"
trigger:
- platform: time
at: "04:00:00"
action:
- service: unraid.execute_command
data:
entry_id: "1234abcd5678efgh"
command: "docker system prune -f"
Monitor container status through the switch entity's state:
-
on
= Container is running -
off
= Container is stopped
service: unraid.execute_in_container
data:
entry_id: "1234abcd5678efgh"
container: "plex"
command: "tail -n 100 /config/Plex Media Server/Logs/Plex Media Server.log"
-
Graceful Shutdown
- Allow sufficient time for containers to stop
- Use appropriate stop signals
- Monitor shutdown completion
-
Resource Management
- Monitor container resource usage
- Schedule maintenance during off-peak hours
- Clean up unused containers/images
-
Error Handling
- Implement retry logic
- Add notification on failures
- Log important events
-
Security
- Use specific commands instead of shell access
- Limit command execution privileges
- Monitor container security logs