Skip to main content

Docker

anycloud deploys Docker containers to cloud VMs. If you're new to Docker, here's what you need to know.

What is Docker?

Docker packages your application and its dependencies into a container — a lightweight, portable unit that runs the same way everywhere. Think of it as a zip file for your entire app environment.

Images and Containers

  • Image — a blueprint for your app (code + dependencies + OS). Built from a Dockerfile.
  • Container — a running instance of an image. anycloud creates one container per VM.

Using Existing Images

You can run any public image from Docker Hub, GHCR, or other registries without building anything:

anycloud submit python:3.11 -- python train.py
anycloud submit pytorch/pytorch:2.1.0-cuda12.1-cudnn8-runtime --gpu h100:8

This is the fastest way to get started — pick an image that has the runtime you need and pass your command directly.

Building and Pushing

When existing images don't have your dependencies, build a custom one. A Dockerfile tells Docker how to build one:

FROM python:3.11

WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .

CMD ["python", "train.py"]

You can build images however you like — docker build && docker push, your CI pipeline, or anycloud build. anycloud just needs a pullable image reference.

anycloud build

anycloud build builds your image on a remote VM and pushes it to GitHub Container Registry (GHCR):

anycloud build

This provisions a VM, runs docker build remotely, and pushes the image as ghcr.io/{user}/{repo}:latest. No local Docker installation required. Use --target to push to a different GHCR repository (public or private):

anycloud build --target ghcr.io/my-org/my-image:v1.0

Programmatic Images (Python SDK)

Instead of writing a Dockerfile, you can define images in Python with chainable methods:

import anycloud

image = (
anycloud.Image.debian_slim(repository="ghcr.io/user/train")
.pip_install("torch", "transformers")
.apt_install("curl")
.env({"HF_HOME": "/root/models"})
.workdir("/app")
)

ac = anycloud.Client()
ac.build(image).wait() # builds remotely, pushes to GHCR

You can also extend an existing Dockerfile:

image = anycloud.Image.from_dockerfile("./Dockerfile", repository="ghcr.io/user/train")
.pip_install("extra-dep")

See Python SDK — Custom Images for the full API.

Submitting

anycloud submit runs any image — public or private — on a cloud VM:

anycloud submit ghcr.io/user/train:latest --gpu h100:8

For private images, anycloud supports GHCR — anycloud login authenticates via GitHub OAuth, and anycloud uses your token to pull the image on the VM. Other private registries are not currently supported.

tip

If you use the @anycloud.function() decorator, your code is synced via git instead of being baked into the image — you only need to rebuild when dependencies change. See Deployment Workflows for when to use each approach.

How anycloud Uses Docker

When you run anycloud submit:

  1. anycloud provisions a VM in your cloud account
  2. Installs Docker on the VM
  3. Pulls your image from the registry (for private GHCR images, authenticates with your GitHub token)
  4. Starts your container with docker run

Your container runs as if it were on your local machine — same environment, same dependencies, same behavior. After the first deploy, anycloud snapshots the VM disk so subsequent deploys of the same image skip the pull entirely. See Image Caching.

Docker Runtime Options

You can pass standard Docker runtime flags to control resource limits for any workload:

anycloud submit my-image --shm-size 8g --memory 32g --cpus 4 --ipc host
FlagDescription
--shm-sizeShared memory size (e.g., 8g)
--memoryMemory limit (e.g., 32g)
--cpusCPU limit
--ipcIPC mode (host, private, shareable)
--ulimitUlimit settings (can specify multiple)

GPU Support

For GPU workloads, pass --gpus and --runtime:

anycloud submit my-image --gpus all --runtime nvidia
FlagDescription
--gpusGPU access (all or count)
--runtimeContainer runtime (e.g., nvidia)

Useful Resources