exposed_port pattern for zero-code migration. For an overview of when to use a Dockerfile versus pip requirements, see Environment and Runtime.
Basic Usage
UseContainerImage.from_dockerfile_str() to define your Dockerfile inline, or ContainerImage.from_dockerfile() to reference a file on disk.
For a complete walkthrough deploying a containerized app, see the custom containers example.
fal Platform Requirements
fal injects a small runtime into your container to manage serialization, file uploads, and endpoint serving. Your Dockerfile must satisfy two requirements:curlmust be installed. fal uses it during runner startup.pydantic,protobuf, andboto3must be compatible with the fal SDK. The easiest way to ensure this is to install thefalpackage itself as the last step in your Dockerfile, which brings in the correct versions. Alternatively, install these three packages last so they override any conflicting versions from your other dependencies.
COPY and Build Context
fal supports standard DockerCOPY and ADD commands to include local files in your container builds. Paths are resolved relative to the current working directory (where you run fal deploy), or you can specify a custom context_dir.
Supported COPY Patterns
Files uploaded via
app_files are already in the build context and will not be re-uploaded. fal uses content-based hashing to deduplicate files. The file containing your fal.App class is not part of the container image - it is pickled and sent at deploy time, so changes to your app code do not trigger a container rebuild..dockerignore
Create a.dockerignore file in your project to exclude files from the build context, or define patterns in code:
.dockerignore exists, fal uses sensible defaults that exclude common development artifacts.
Alternative: Upload Large Files to CDN
For very large files or files that change independently from your container, you can upload them to fal’s CDN and download them during the build:ADD command to download directly from a URL:
Cache Behavior
Container images are cached based on Dockerfile content, build secrets, and the content hash of all context files. Changing any local file (except the app file itself) or a secret triggers a rebuild. The app file containing yourfal.App class is not baked into the image - it is pickled and sent at deploy time, so changes to your app code do not trigger a container rebuild.
To force a rebuild, pass --no-cache:
Build Secrets
Use BuildKit secret mounts to pass secrets at build time without baking them into image layers. Secret values prefixed with$ are resolved from your fal secrets.
Build Args
Usebuild_args to pass standard Docker build arguments. Build args are not secret and are visible in image layers.
Using Private Registries
If your base image is hosted on a private registry (Docker Hub, Google Artifact Registry, or AWS ECR), you provide credentials via theregistries parameter. See Private Registries for step-by-step authentication setup.
ContainerImage Parameters
BothContainerImage.from_dockerfile_str() and ContainerImage.from_dockerfile() accept the following parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
build_args | Dict[str, str] | {} | Docker --build-arg values |
secrets | Dict[str, str] | {} | BuildKit --secret values (not baked into layers) |
registries | Dict[str, Dict] | {} | Private registry credentials |
context_dir | Path | Current directory | Build context directory |
dockerignore | List[str] | Default patterns | Patterns to exclude from context |
dockerignore_path | Path | None | Path to .dockerignore file |
compression | str | "gzip" | Image layer compression ("gzip", "zstd") |
force_compression | bool | False | Force re-compression of all layers |
build_args
Docker build arguments passed as--build-arg during image build. Use to parameterize your Dockerfile.
secrets
Build-time secrets mounted via BuildKit--secret. Unlike build_args, secrets are not baked into image layers. Use for private package indexes or git tokens. Values prefixed with $ are resolved from your fal secrets at build time.
context_dir
The build context directory. Files from this directory are available viaCOPY in your Dockerfile. Defaults to the current working directory.
dockerignore / dockerignore_path
Inline list of patterns to exclude from the build context, or a path to an external.dockerignore file. See the .dockerignore section above for examples.
Pre-Deploy Checklist
Before deploying, verify:- All package versions are pinned
curlis installed- fal-compatible versions of pydantic, protobuf, and boto3 are installed (either via
pip install falor by installing them last) - Container builds successfully with
fal run