Runpod Pods use custom Docker images, so you can’t directly build Docker containers or use Docker Compose on a GPU Pod. However, you can use Bazel to build and push Docker images from inside a Pod, effectively creating a “Docker in Docker” workflow.Documentation Index
Fetch the complete documentation index at: https://runpod-b18f5ded-promptless-remove-flash-beta-notification.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Requirements
Before starting, you’ll need:- A Docker Hub account with an access token.
- A Runpod account with credits.
Step 1: Deploy a Pod
- Navigate to Pods and select + Deploy.
- Choose GPU or CPU based on your needs.
- Select an instance type (for example, A40).
- (optional) Attach a for larger image builds.
- Select a (for example, Runpod Pytorch).
- Select Deploy On-Demand.
- Select Connect.
- Select Start Web Terminal, then Connect to Web Terminal.
Step 2: Install dependencies
Install the required tools:-
Update packages and install sudo:
-
Install Docker:
-
Log in to Docker Hub:
- Go to Docker Hub Security Settings and create an access token with Read/Write permissions.
-
Log in to Docker Hub, replacing
YOUR_USERNAMEwith your actual Docker Hub username:When prompted for a password, paste your access token (not your Docker Hub password).
-
Install Bazel via Bazelisk:
-
Verify the installations:
You should see version numbers for both Docker and Bazel.
Step 3: Create the project files
Create a new directory for your Bazel project:.bazelversion file to pin to a stable Bazel version:
MODULE.bazel file (required by Bazel 7+):
WORKSPACE file that declares your dependencies:
BUILD.bazel file that defines the image build:
Step 4: Configure your Docker Hub username
Usesed to replace the username placeholder with your Docker Hub username in BUILD.bazel. Replace YOUR_ACTUAL_USERNAME with your actual Docker Hub username:
Step 5: Build and push the image
Run the Bazel command to build and push the Docker image:your_username/custom_image:latest.
Understanding the build files
.bazelversion
This file pins the Bazel version to ensure reproducible builds. Bazelisk reads this file and automatically downloads the specified version.WORKSPACE
This file declares your project’s external dependencies:http_archive: Downloads the rules_oci package from GitHub.rules_oci_dependencies: Loads transitive dependencies.oci_register_toolchains: Registers the OCI toolchain (crane) for building images.oci_pull: Pulls a base Docker image that your custom image builds on top of.
BUILD.bazel
This file defines what to build:oci_image: Creates a new container image by adding layers to a base image.genrule: Creates a tar file containing custom content to add to the image.oci_push: Pushes the built image to a container registry.
Next steps
- Use your custom image in a Runpod template.
- Explore rules_oci documentation for more advanced configurations.
- Learn how to manage Pods using the Runpod console, CLI, and REST API.