Prerequisites
Before you begin, ensure you have:- Python 3.6 or higher installed
- Docker installed and running
- pip package manager
Create your first containerized app
Install Buildr
Install the metaparticle_pkg library using pip:
Buildr is distributed as
metaparticle_pkg on PyPI. The package includes Docker SDK for Python as a dependency.Create your application
Create a new file called The
hello.py with the following code:@Containerize decorator tells Buildr to:- Build a container image named
myrepo/hello-app:latest - Run the application inside that container
Run your application
Execute your application:You’ll see Buildr:
- Generate a Dockerfile
- Build the container image
- Run your application inside the container
- Stream the logs to your terminal
Add runtime configuration
Let’s create a web server with port configuration:runtime parameter configures:
- ports: Which ports to expose from the container
- executor: Which runtime to use (docker or metaparticle)
- replicas: Number of container instances to run
- public: Whether to expose the service publicly
Publish to a registry
To publish your container image to Docker Hub or another registry:Configuration options
The@Containerize decorator accepts two main parameters:
Package options
- repository (required): Container registry repository
- name: Container name (defaults to current directory name)
- builder: Build system to use (default: ‘docker’)
- publish: Whether to push to registry (default: False)
- verbose: Enable verbose logging (default: True)
- quiet: Suppress output (default: False)
- py_version: Python version for base image (default: 3)
Runtime options
- executor: Execution environment - ‘docker’ or ‘metaparticle’ (default: ‘docker’)
- replicas: Number of container instances (default: 0)
- ports: List of ports to expose (default: [])
- public: Make service publicly accessible (default: False)
Next steps
Now that you’ve created your first containerized application, you can:- Explore advanced configuration options
- Learn how to deploy with multiple replicas
- Understand how Buildr generates Dockerfiles
- Deploy to Kubernetes using the metaparticle executor