Self-Update
Drydock can gracefully update itself when a new version is available.
Drydock can gracefully update itself when a new version is available, using a safe rollback-capable process that ensures zero downtime.
How it works
Drydock detects when its own container image has an update available, just like any other monitored container. When the Docker trigger runs for the drydock container, it uses a special self-update flow that ensures zero downtime and safe rollback.
Requirements
- The Docker socket must be bind-mounted at
/var/run/docker.sock - The Docker trigger must be enabled
- Drydock must be able to create temporary helper containers
dd.hook.pre / dd.hook.post) are NOT executed during self-update.Update sequence
- Notify UI — A
dd:self-updateSSE event is broadcast to all connected browsers, displaying an animated full-screen overlay. The server waits for at least one browser to acknowledge receipt before proceeding (see SSE acknowledgment below) - Backup current image — The running image is backed up before proceeding
- Pull new image — The updated image is pulled while the current container is still running
- Rename old container — The current container is renamed to
drydock-old-{timestamp}to free the original name - Create new container — A new container is created with the original name and updated image (not started yet)
- Helper container — A temporary container is spawned with the Docker socket mounted. It:
- Stops the old container
- Starts the new container
- Deletes the old container on success
- If the new container fails to start, restarts the old container as a fallback
- Reconnect — The UI automatically reconnects to the new container
Error recovery
If any step fails, drydock attempts to restore the previous state:
- If new container creation fails, the old container is renamed back to its original name
- If the helper container fails to spawn, the new container is removed and the old container is renamed back
- If the new container fails to start, the helper restarts the old container
SSE acknowledgment
When the self-update begins, the server needs to ensure that connected browsers have received the update notification and displayed the overlay before the container is replaced. This is handled by an ack flow:
- Each SSE client receives a
clientIdandclientTokenwhen it connects to the/api/events/uiendpoint (via add:connectedevent). - When the
dd:self-updateevent is broadcast, the server records which client tokens were connected at that moment. - Browsers acknowledge the event by sending
POST /api/events/ui/self-update/:operationId/ackwith theirclientIdandclientToken. - Once at least one acknowledgment is received (or the timeout expires), the update proceeds.
The ack timeout defaults to 3 seconds. If no browsers are connected, the update proceeds immediately without waiting.
Dry-run mode
When DD_TRIGGER_DOCKER_{trigger_name}_DRYRUN=true, the self-update is logged but not executed. The new image is pulled ahead of time but no container replacement occurs.
Example
services:
drydock:
image: codeswhat/drydock:latest
container_name: drydock
labels:
- dd.watch=true
environment:
- DD_TRIGGER_DOCKER_LOCAL_PRUNE=true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- drydock-data:/store
ports:
- "3000:3000"
volumes:
drydock-data: