Auto-update Docker containers on new image digests with Docker API
UnknownWhat this workflow does
This workflow has 14 nodes and runs on a schedule (every hour). Along the way it connects Docker Api (community).
How it runs
Trigger: On a schedule (every hour).
- Settings (Edit Fields (Set)): sets 4 fields: containerName, image, hostPort…
- Check registry for a new digest (Docker): distribution inspect (image)
- Inspect the local image (Docker): inspect image
- Has the image changed? (Code): runs custom JavaScript code
- Update needed? (If): checks a condition and branches into true / false
- Pull the new image (Docker): pull image
- Remove the old container (Docker): remove (container)
- Create the new container (Docker): create (container)
- Wait until it is healthy (Docker): wait for state (container)
- Did it come up healthy? (If): checks a condition and branches into true / false
Services it uses
Before you upgrade to n8n 3.0
We can't fully verify this one: it relies on 1 community package, and n8n 3.0 turns unverified community packages off by default (N8N_UNVERIFIED_PACKAGES_ENABLED=false).
- Check that n8n-nodes-docker-api is verified or supports 3.0 (used in Check registry for a new digest, Inspect the local image, Pull the new image).
Nodes used (6)
- Schedule Trigger
n8n-nodes-base.scheduleTrigger - Edit Fields (Set)
n8n-nodes-base.set - Docker
n8n-nodes-docker-api.docker - Code
n8n-nodes-base.code - If
n8n-nodes-base.if - No Operation, do nothing
n8n-nodes-base.noOp
From the author
Quick overview This workflow runs hourly to check a Docker registry for updated image digests, and if a new image is available it pulls it, recreates a Docker container with the configured port mapping, and waits for the container health check to pass. How it…