sudo apt -y install python3 python3-pip
Podman supports the Kubernetes YAML format for configuring pods. Unfortunately, I’m coming to the Podman scene from Docker where the Docker Compose format is common. The Docker Compose format isn’t supported by Podman. I don’t really want to invest the time in learning a new configuration file format right now, so what should I do? Use Podman Compose!
This tutorial describes how to use a Docker Compose file with Podman to create a rootless container. It uses the Docker Compose for the UniFi Controller described in the UniFi Controller post. This tutorial targets Ubuntu 18.04, and you should be familiar with Linux Containers, Docker Compose, Podman, Python, and the command-line. You’ll need to have Podman installed on your machine, which can be installed on Ubuntu 18.04 by following the instructions in the post Install Podman on Ubuntu.
Since Podman Compose is a Python tool, install Python 3 and pip.
sudo apt -y install python3 python3-pip
Now using pip, install the latest development version of Podman Compose.
pip3 install --user https://github.com/containers/podman-compose/archive/devel.tar.gz
Add ~/.local/bin
to your PATH
.
fish_add_path ~/.local/bin
echo "set PATH=$HOME/.local/bin:$PATH" >> ~/.zshrc; source ~/.zshrc
echo "set PATH=$HOME/.local/bin:$PATH" >> ~/.bashrc; source ~/.bashrc
Create a directory for the Docker Compose file.
mkdir -p ~/Projects/unifi-controller
Change to the new directory.
cd ~/Projects/unifi-controller
Create the Docker Compose file.
---
version: "2.1"
services:
unifi-controller:
image: ghcr.io/linuxserver/unifi-controller
environment:
- MEM_LIMIT=1024M #optional
volumes:
- data:/config
ports:
- 3478:3478/udp
- 10001:10001/udp
- 8080:8080
- 8443:8443
- 1900:1900/udp #optional
- 8843:8843 #optional
- 8880:8880 #optional
- 6789:6789 #optional
- 5514:5514/udp #optional
restart: unless-stopped
labels:
io.containers.autoupdate: image (1)
volumes:
data:
1 | Spoiler! I’ll be describing how to automatically update container images with Podman in an upcoming blog post. |
This Docker Compose uses the docker-unifi-controller image provided by LinuxServer.io and is very close to the provided Docker Compose file.
It uses a volume to store persistent data.
The volume dubbed data here will use a Podman volume named unifi-controller_data
.
From within the project directory, run Podman Compose to create the unifi-controller pod.
Just like when using Docker Compose, the up
subcommand creates and starts the container, and the -d
flag backgrounds the process.
podman-compose up -d
Access the controller’s web console at https://127.0.0.1:8443/.
open http://127.0.0.1:8443
xdg-open http://127.0.0.1:8443
If you’d like to learn more about using Podman Compose, checkout the article Manage containers with Podman Compose from Fedora Magazine.
That was fast, wasn’t it? Love Podman yet? If you want to simplify your workflow, checkout Translate Docker Compose to Kubernetes With Podman.