When we must choose between Docker or Podman?
A lot of times we find that there are very few resources and we need an environment to perform a complete product demonstration at customer.
In those cases we’ll need to simulate an environment in the simplest way possible and with minimal resources. For this we’ll adopt containers, but which is the best solution for those small environments?
Docker is the standard container environment, it is the most widespread and put together a set of powerful tools such as a client on the command line, an API server, a container lifecycle manager (containerd), and a container launcher (runc).
Install docker is easy, since docker supplies a script that execute the process of prepare and configure the necessary requirements and repositories and finally installs and configures docker leaving the service ready to use.
Podman is a container environment that does not use a service and therefore does not have an API server, requests are made only from the command line, which has advantages and disadvantages that we will explain at the article.
Install podman is easy in a Centos environment (
yum install -y podman for Centos 7 and
yum install -y container-tools for Centos 8) but you need some work in a Debian environment:
# sudo apt update && sudo apt install -y software-properties-common dirmngr # sudo apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 0x018BA5AD9DF57A4448F0E6CF8BECF1637AD8C79D # sudo sh -c "echo 'deb http://ppa.launchpad.net/projectatomic/ppa/ubuntu bionic main' /etc/apt/sources.list.d/container.list" # sudo apt update && sudo apt install -y podman skopeo buildah uidmap debootstrap
Deploy with Ansible
In our case we have used the Ansible roles developed at https://github.com/aescanero/disasterproject, to deploy two virtual machines, one with podman and the other with docker.
In the case of using a Debian based distribution we must to install Ansible:
$ sudo sh -c 'echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" /etc/apt/sources.list' $ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 $ sudo apt-get update && sudo apt-get install -y ansible
We proceed to download the environment and configure Ansible:
$ git clone https://github.com/aescanero/disasterproject $ cd disasterproject/ansible $ chmod 600 files/insecure_private_key
Edit the inventory.yml file which must have the following format:
all: children: vms: hosts: MACHINE_NAME1: memory: MEMORY_IN_MB vcpus: vCPUS_FOR_VM vm_ip: "IP_VM_MACHINA_NAME1" linux_flavor: "debian|centos" container_engine: "docker|podman" MACHINE_NAME2: memory: MEMORY_IN_MB vcpus: vCPUS_FOR_VM vm_ip: "IP_VM_MACHINA_NAME2" linux_flavor: "debian|centos" container_engine: "docker|podman" vars: network_name: NETWORK_NAME network: "VM_NETWORK"
There are some global variables that hang from “vars:”, which are:
- network_name: Descriptive name of the libvirt network that we will use and that will also be the name of the interface that will be configured on the KVM host and that will serve as the gateway of the virtual machines
- network: the first three fields of the IPv4 address to conform a network with mask 255.255.255.0, virtual machines must have an IP of that range (minus .1 and .255)
The format of each machine is defined by the following attributes:
- machine_name: Descriptive name of the virtual machine to be deployed, it will also be the hostname of the virtual machine.