Docker Containers
This guide explains how to use existing Docker containers and create custom ones for your Bacalhau workloads.
Prerequisites
- Install the Bacalhau client
- Docker (for both building custom containers and running on compute nodes)
Understanding Docker Workloads in Bacalhau
Bacalhau uses a syntax that closely resembles Docker, allowing you to utilize the same containers.
Example: Docker Command
docker run alpine echo "Hello from Docker"
Equivalent Bacalhau Command
bacalhau docker run alpine echo "Hello from Bacalhau"
Getting Job Results
# View job logs
bacalhau job logs JOB_ID
# Get detailed job information
bacalhau job describe JOB_ID
Requirements for Docker Containers
Containers must be published to a registry that is accessible to your Bacalhau nodes
Creating a Custom Container
Let's walk through creating a simple custom Docker container for Bacalhau.
Step 1: Create Your Container Files
Create a simple Dockerfile:
FROM alpine:latest
RUN echo '#!/bin/sh\necho "Hello from $1"' > /usr/local/bin/greet && \
chmod +x /usr/local/bin/greet
Step 2: Build and Test Your Container Locally
Build your Docker image:
docker build -t your-registry/simple-greeter:latest .
Test it locally:
docker run --rm your-registry/simple-greeter:latest sh -c 'greet "Local Test"'
Step 3: Push Your Container to a Registry
# For multi-architecture support (recommended)
docker buildx build --platform linux/amd64,linux/arm64 --push -t your-registry/simple-greeter:latest .
# For single architecture
docker push your-registry/simple-greeter:latest
Running Your Custom Container on Bacalhau
Run your container on Bacalhau:
bacalhau docker run your-registry/simple-greeter:latest \
sh -c 'greet "Bacalhau"'
View your job logs:
bacalhau job logs JOB_ID