Docker Tag Sync Extension
Tags Docker images with the new version after successful version bumps.
post-bumpBashv1.0.0
Features
- Automatically tags Docker images with the version number
- Configurable version prefix (e.g.,
v1.2.3or1.2.3) - Optional push to registry after tagging
- Support for custom source tags (not just
latest) - Optional "also tag as latest" functionality
Requirements
- Docker CLI installed and accessible
- Source image must exist locally (build before bumping)
- For push: authenticated to the target registry
Installation
Install directly from the sley repository:
bash
sley extension install --url github.com/indaco/sley/contrib/extensions/docker-tag-syncOr from a local clone:
bash
sley extension install --path ./contrib/extensions/docker-tag-syncConfiguration
Add to your .sley.yaml:
yaml
extensions:
docker-tag-sync:
# Required: Docker image name
image: "myapp"
# Optional: Source tag to re-tag (default: "latest")
source-tag: "latest"
# Optional: Version prefix for the tag (default: "v")
prefix: "v"
# Optional: Push to registry after tagging (default: false)
push: false
# Optional: Also update the "latest" tag (default: false)
also-tag-latest: false
# Optional: Registry (if not included in image name)
registry: "docker.io/myorg"Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
image | string | (required) | Docker image name |
source-tag | string | "latest" | Source tag to re-tag |
prefix | string | "v" | Version prefix for the tag |
push | bool | false | Push to registry after tagging |
also-tag-latest | bool | false | Also update the "latest" tag |
registry | string | - | Registry (if not included in image name) |
Examples
Basic Usage
Tag local image with version:
yaml
extensions:
docker-tag-sync:
image: "myapp"bash
# Build your image first
docker build -t myapp:latest .
# Bump version - automatically tags myapp:v1.2.4
sley bump patchWith Registry Push
Tag and push to Docker Hub:
yaml
extensions:
docker-tag-sync:
image: "myorg/myapp"
push: trueWith Custom Registry
Tag and push to private registry:
yaml
extensions:
docker-tag-sync:
image: "myapp"
registry: "ghcr.io/myorg"
push: true
also-tag-latest: trueThis will:
- Tag
myapp:latestasghcr.io/myorg/myapp:v1.2.4 - Tag
myapp:latestasghcr.io/myorg/myapp:latest - Push both tags to GitHub Container Registry
CI/CD Integration
Example GitHub Actions workflow:
yaml
- name: Build Docker image
run: docker build -t myapp:latest .
- name: Bump version and tag image
run: sley bump patch
- name: Push to registry
run: |
docker push myapp:v${{ steps.version.outputs.new }}Or configure push in .sley.yaml for automatic pushing:
yaml
extensions:
docker-tag-sync:
image: "ghcr.io/myorg/myapp"
push: trueHow It Works
- After a successful version bump, the extension receives the new version
- It looks for the source image (default:
image:latest) - Tags the source image with the new version tag
- Optionally pushes to the registry
Error Handling
The extension will fail (and report the error) if:
- The source image doesn't exist locally
- Docker tagging fails
- Push fails (if enabled)
WARNING
The version bump itself will still succeed - only the Docker tagging step fails.
Troubleshooting
| Issue | Solution |
|---|---|
| "Source image not found" | Build your Docker image before running version bump |
| "Failed to push" | Ensure you're authenticated (docker login) |
| Wrong source tag | Use source-tag option for non-latest tags |
Using a different source tag
If your CI builds with a different tag (e.g., commit SHA):
yaml
extensions:
docker-tag-sync:
image: "myapp"
source-tag: "sha-abc123"See Also
- Extension System - Creating custom extensions
- Tag Manager Plugin - Git tag automation
- CI/CD Integration - Automate Docker tagging in pipelines
- Usage Guide - Version bump commands
- .sley.yaml Reference - Extension configuration
- Troubleshooting - Common Docker integration issues