Podman Extension (Experimental)
Experimental
This feature is experimental and may change in future releases.
Info
Sugar's podman-ext extension includes both standard Podman commands and experimental features like attach, cp, ls, scale, and watch that won't work currently in container operations.
Sugar provides support for Podman Compose through the podman-ext extension.
This extension allows you to use Podman as a container engine backend instead of
Docker.
Overview
Podman is a daemonless container engine for developing, managing, and running
OCI containers on your Linux system. The podman-ext extension in Sugar
provides a seamless interface to work with Podman Compose, similar to how you
would use Docker Compose.
Prerequisites
To use the podman-ext extension, you need to have the following installed:
- Podman (latest version recommended)
- podman-compose
You can install podman-compose using pip:
pip install podman-compose
Configuration
The configuration for Podman extension is the same as for Docker Compose. You
need to specify the backend, groups, and other parameters in the .sugar.yaml
file:
backend: podman
defaults:
group: development
groups:
development:
project-name: my-project
config-path:
- containers/compose.yaml
env-file: .env
services:
default:
- app
- database
available:
- name: app
- name: database
- name: redis
Commands
The podman-ext extension provides the same set of commands as the Docker
Compose extension. Here are the available commands:
Basic Commands
sugar podman-ext build: Build or rebuild servicessugar podman-ext config: Parse, resolve and render compose file in canonical formatsugar podman-ext create: Create servicessugar podman-ext down: Stop and remove containers, networkssugar podman-ext exec: Execute a command in a running containersugar podman-ext images: List images used by the created containerssugar podman-ext kill: Kill containerssugar podman-ext logs: View output from containerssugar podman-ext pause: Pause servicessugar podman-ext ps: List containerssugar podman-ext pull: Pull service imagessugar podman-ext push: Push service imagessugar podman-ext restart: Restart servicessugar podman-ext rm: Remove stopped containerssugar podman-ext run: Run a one-off command on a servicesugar podman-ext start: Start servicessugar podman-ext stop: Stop servicessugar podman-ext top: Display running processessugar podman-ext unpause: Unpause servicessugar podman-ext up: Create and start containerssugar podman-ext version: Show the podman-compose version information
Experimental Commands
sugar podman-ext attach: Attach to a service's containersugar podman-ext cp: Copy files/folders between a container and the local filesystemsugar podman-ext ls: List containerssugar podman-ext scale: Scale servicessugar podman-ext wait: Block until the first service container stopssugar podman-ext watch: Watch build context for service source code changes and rebuild/refresh containers
How to Use
You can use the podman-ext extension just like you would use the standard
Docker Compose commands with Sugar. Here are some examples:
Building Services
# Build default services defined in the configuration
sugar podman-ext build
# Build all services, ignoring defaults
sugar podman-ext build --all
# Build specific services
sugar podman-ext build --services app,database
Running Services
# Start default services
sugar podman-ext start
# Start all services in detached mode
sugar podman-ext start --all -- -d
# Start specific services in detached mode
sugar podman-ext start --services app,database -- -d
Executing Commands
# Execute a command in a running service container
sugar podman-ext exec --service app --cmd "python manage.py migrate"
# Get a shell in a running service container
sugar podman-ext exec --service database --cmd "bash"
Environment Variables
Like the Docker Compose extension, the Podman extension supports the use of
environment variables specified in the env-file parameter:
groups:
development:
env-file: .env
# Other configuration...
Differences from Docker Compose
While Sugar aims to provide a consistent interface for both Docker Compose and Podman Compose, there are some differences to be aware of:
- Podman Compose uses
-finstead of--filefor specifying compose files (handled automatically by Sugar) - Podman Compose uses
-pinstead of--project-namefor specifying project names (handled automatically by Sugar) - Podman Compose doesn't directly support the
--env-fileflag, so Sugar loads the environment variables before executing commands
Note
- There is no such flag
-dpresent in--forsugar podman-ext start. - Experimental commands like
attach,cp,ls,scale, andwatchmay have different behavior between Podman versions. These commands are not supported currently in Sugar - The
waitcommand is still in development.
Troubleshooting
If you encounter issues with the Podman extension:
- Make sure Podman and podman-compose are properly installed and accessible in your PATH
- Check that your
.sugar.yamlconfiguration is correctly set up - Run commands with the
--verboseflag to see detailed output - If a command fails, check the error message for clues about what went wrong
For more advanced troubleshooting, you can also directly use podman-compose commands to verify functionality outside of Sugar.