Example: Using Custom Containers with fal Apps
Here’s a complete example demonstrating how to use custom containers withfal
.
Detailed Explanation
- Importing fal and ContainerImage:
- Creating a Dockerfile String:
A multi-line string (
dockerfile_str
) is defined, specifying the base image aspython:3.11
, and installingffmpeg
andpyjokes
packages.
Version mismatchEnsure that the Python version in the Dockerfile matches the Python version in
your local environment that you use to run the app.This is required to avoid any compatibility issues. We use
pickle
to serialize
the app under the hood, and the Python versions must match to avoid any
serialization issues.That being said, we are constantly working on improving this experience.Running the App
To run the app, save the code to a file (e.g.,test_container.py
) and execute it using the fal run
command: