6.3 KiB
Publishing BDFR Web Interface to Docker Hub
This guide covers how to build and push the Docker image to Docker Hub.
Prerequisites
- Docker Hub Account: Create one at https://hub.docker.com if you don't have one
- Docker installed: Ensure Docker is running on your machine
Step 1: Login to Docker Hub
Open your terminal and login:
docker login
Enter your Docker Hub username and password when prompted.
Step 2: Build the Image with Proper Tagging
Build the image with your Docker Hub username and desired repository name:
# Replace 'yourusername' with your actual Docker Hub username
# Replace 'bdfr-web' with your desired repository name (or keep it)
docker build -t yourusername/bdfr-web:latest .
# You can also add version tags
docker build -t yourusername/bdfr-web:latest -t yourusername/bdfr-web:1.0.0 .
Example:
docker build -t danielsmith/bdfr-web:latest -t danielsmith/bdfr-web:1.0.0 .
Step 3: Test the Image Locally (Optional but Recommended)
Before pushing, verify the image works:
docker run -d -p 8000:8000 \
-v $(pwd)/downloads:/downloads \
-v $(pwd)/data:/app/data \
--name bdfr-test \
yourusername/bdfr-web:latest
Visit http://localhost:8000 to verify it works, then clean up:
docker stop bdfr-test
docker rm bdfr-test
Step 4: Push to Docker Hub
Push the image to Docker Hub:
# Push latest tag
docker push yourusername/bdfr-web:latest
# If you created a version tag, push that too
docker push yourusername/bdfr-web:1.0.0
Step 5: Verify the Push
- Go to https://hub.docker.com
- Navigate to your repositories
- You should see
bdfr-weblisted - Click on it to see tags and details
Using the Published Image
Others can now pull and use your image:
docker pull yourusername/bdfr-web:latest
docker run -d -p 8000:8000 -v ./downloads:/downloads yourusername/bdfr-web:latest
Or using docker-compose, update docker-compose.yml:
services:
bdfr-web:
image: yourusername/bdfr-web:latest # Replace 'build:' section with this
# ... rest of configuration
Automated Build with Docker Hub
You can set up automated builds that trigger when you push to GitHub:
- Go to https://hub.docker.com
- Navigate to your repository
- Click "Builds" tab
- Click "Configure Automated Builds"
- Connect your GitHub account
- Select your repository
- Configure build rules (e.g., build on push to main branch)
Multi-Platform Builds (Optional)
To build for multiple architectures (amd64, arm64, etc.):
Setup buildx (one-time setup)
# Create a new builder
docker buildx create --name multiplatform --use
# Bootstrap the builder
docker buildx inspect --bootstrap
Build and push multi-platform image
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t yourusername/bdfr-web:latest \
-t yourusername/bdfr-web:1.0.0 \
--push \
.
This creates images that work on both x86_64 (Intel/AMD) and ARM64 (Apple Silicon, Raspberry Pi, etc.).
Updating Your Published Image
When you make changes:
- Update version: Increment version in tags (e.g., 1.0.0 → 1.0.1)
- Rebuild:
docker build -t yourusername/bdfr-web:latest -t yourusername/bdfr-web:1.0.1 . - Push:
docker push yourusername/bdfr-web:latest docker push yourusername/bdfr-web:1.0.1
Best Practices
Tagging Strategy
latest: Always points to the most recent stable build1.0.0,1.0.1: Specific version tags for reproducibility1.0,1: Major/minor version tagsdev: Development/unstable builds
Example tagging:
docker build -t yourusername/bdfr-web:latest \
-t yourusername/bdfr-web:1.0.1 \
-t yourusername/bdfr-web:1.0 \
-t yourusername/bdfr-web:1 .
Repository Description
Add a good description to your Docker Hub repository:
- Go to your repository on Docker Hub
- Click "Description" tab
- Add a README with:
- What the image does
- How to use it
- Environment variables
- Volume mounts
- Example docker-compose.yml
Size Optimization
Current image uses multi-stage builds and is already optimized. To check size:
docker images yourusername/bdfr-web
Complete Script
Here's a complete script to build and push (save as publish-docker.sh):
#!/bin/bash
set -e
# Configuration
DOCKER_USERNAME="yourusername"
IMAGE_NAME="bdfr-web"
VERSION="1.0.0"
# Build
echo "Building Docker image..."
docker build -t ${DOCKER_USERNAME}/${IMAGE_NAME}:latest \
-t ${DOCKER_USERNAME}/${IMAGE_NAME}:${VERSION} .
# Test
echo "Testing image..."
docker run --rm ${DOCKER_USERNAME}/${IMAGE_NAME}:latest bdfr --version
# Login (if not already logged in)
echo "Logging in to Docker Hub..."
docker login
# Push
echo "Pushing to Docker Hub..."
docker push ${DOCKER_USERNAME}/${IMAGE_NAME}:latest
docker push ${DOCKER_USERNAME}/${IMAGE_NAME}:${VERSION}
echo "Done! Image published to:"
echo " docker pull ${DOCKER_USERNAME}/${IMAGE_NAME}:latest"
echo " docker pull ${DOCKER_USERNAME}/${IMAGE_NAME}:${VERSION}"
Make it executable:
chmod +x publish-docker.sh
./publish-docker.sh
Troubleshooting
"denied: requested access to the resource is denied"
- Make sure you're logged in:
docker login - Verify your username in the image tag matches your Docker Hub username
- Check that the repository exists or that you have permissions
"image not found" after push
- Wait a few minutes - Docker Hub indexing can be delayed
- Refresh the Docker Hub web page
- Try pulling:
docker pull yourusername/bdfr-web:latest
Large image size
Current image should be ~500-800MB. If larger:
- Check that
.dockerignoreis working - Verify multi-stage build is being used
- Clean up any unnecessary files in the image
Private Repositories
To make your repository private:
- Go to Docker Hub repository settings
- Change visibility to "Private"
- Users will need to login to pull:
docker loginbeforedocker pull