Podman is a free, open-source, drop-in Docker replacement for running containers. These examples deploy containers in podman using Ansible.
There are many registries with repositories of official container images:
- docker.io (Docker)
- quay.io (Red Hat)
- ghcr.io (GitHub)
- azurecr.io (Microsoft Azure)
For Mac, Podman is provided through Homebrew. Once you have set up brew, you can use the brew install
command to install Podman:
brew install podman
brew install podman-desktop # manage containers via UI
brew install podman-compose # optional for dockerfiles and Kubernetes
Create and start your first Podman machine:
podman machine init # default --disk-size=100GB --memory=2GB
podman machine init --cpus=1 --disk-size=50G --memory=2G --volume $HOME:$HOME
podman machine start
Verify the installation using:
podman info
Launch an NGINX web server container:
cat > index.html <<EOF
<html>
<title>Hello, World!</title>
<h1 style="text-align: center;">Hello, World!</h1>
</html>
EOF
podman run \
--detach --tty --rm \
--publish 8080:80 \
--volume $PWD:/usr/share/nginx/html \
--name nginx \
nginx:latest
curl http://localhost:8080
Uninstall at any time :
podman machine rm -f podman-machine-default --force || true
brew uninstall podman podman-compose podman-desktop
- Create the Python virtual development environment and install Ansible:
python3 -m ensurepip --upgrade
python3 -m pip install --upgrade pip # use a virtual development environment
pipenv install # use Python 3.11 (--python 3.11) or later
pipenv install -r requirements.txt # install required Python packages
- Run the virtual environment:
pipenv shell
- Verify the list of installed Python packages includes Ansible:
pip list
- Verify the Ansible collections includes
ansible.posix
andcontainers.podman
:
ansible-galaxy collection list
Use the community.docker.docker_containers
inventory plugin with Podman!
- Run Podman Desktop
- Verify the Docker socket is redirected to
podman.sock
:
ls -la /var/run/docker.sock
- If not, enable Docker Compatibilty in the status bar at the bottom of the window which installs the
podman-mac-helper
and redirects/var/run/docker
to thepodman.sock
location - Restart Podman Desktop
- Copy this
docker.yml
file to your Ansibleinventory
directory or specify it using the-i {inventory_file}
command line option :
plugin: community.docker.docker_containers
docker_host: unix://var/run/docker.sock
- Run
ansible-inventory
to see your Podman containers!
ansible-inventory --graph
ansible-inventory -i inventory/docker.yml --graph
Example podman commands for managing containers via Ansible :
ansible-playbook podman.yaml --tags containers
ansible-playbook podman.yaml --tags containers -v
ansible-playbook podman.yaml --tags images
ansible-playbook podman.yaml --tags volumes
Use Grafana for monitoring and observability from many different data sources :
ansible-playbook grafana.yaml
Open your web browser to https://localhost:3000 and login with the default username admin
and password admin
.
Use IT Tools at https://it-tools.tech or run your own local instance:
ansible-playbook it-tools.yaml
Use the local container instance at https://localhost:8080.
ansible-playbook ubuntu