Podman vs Docker deploying a WordPress application
Kritik Sachdeva
Technical Support Professional at IBM | RHCA-XII | Openshift | Ceph |Satellite| 3Scale | Gluster | Ansible | Red Hatter
Container technology is the most popular tool used widely for the faster deployment of the application on to servers. There are 3 main tools available that provide these features as docker, podman, or cri-o. In this post, I will show you a demonstration of WordPress application using a docker and podman tool plus what extra benefits provided by the podman over docker.
Docker container works on the principle of client-server hence it is prone to several attacks fro the outer world that is the internet. It is also prone to be a single point of failure as a docker client is the one that actually contacts to docker server.
And due to this client-server architecture, there is a small kind of latency also occurs during the launching of the container.
Podman is another tool for containers, which works on the principle of a daemon less architecture that is there is no client-server architecture. Hence it provides us benefits over docker vulnerabilities. Along with this podman provides us an extra benefit of Kubernetes kind of application architecture.
Deploying WordPress using docker
The process I am using is as: ( We can also the docker-compose)
- Create a new network using docker for inter-connection of containers
docker create network backend --driver bridge
- Launch the database container in the previous network
docker run -dt --restart always -e MYSQL_ROOT_PASSWORD=mysql -e \ MYSQL_DATABASE=wordpress -e MYSQL_USER=wordpress \ -e MYSQL_PASSWORD=wordpress --name db --network backend mysql:5.7
3. Launch the WordPress application in the previous network along with an expose of port 80
docker run -dt -p 8080:80 --restart always -e WORDPRESS_DB_HOST=db:3306 \ -e WORDPRESS_DB_USER=wordpress -e WORDPRESS_DB_PASSWORD=wordpress \ -e WORDPRESS_DB_NAME=wordpress --name wp --network wp-mysql \ wordpress:latest
Now, if you are running on the virtual machine then go the VM IP address:8080 or if you are running on top of cloud then use cloud public IP address:8080 and your wordpress application would be running.
In the case of cloud, you have to first open up or allow 8080 port to be accessible. ( More detail on this topic is not covered in this post )
Deploying WordPress using podman
In this, there are two ways in which we can deploy the application. First is the same way as we used for docker, except that it uses podman or make use extra benefits of podman that is creating a pod.
And here I will use the second approach and steps are:
- Create a pod that is used to maintain the isolated namespace to preserve the network for the containers
podman pod create --name wordpresspod -p 8080:80
To see if it is created or not use the command: podman pod ps
2. Launch the database application inside this pod
podman run -dt --restart always --pod=wordpress \ -e MYSQL_ROOT_PASSWORD=mysql -e \ MYSQL_DATABASE=wordpress -e MYSQL_USER=wordpress \ -e MYSQL_PASSWORD=wordpress --name db --network backend mysql:5.7
3. Launch the wordpress applications inside this pod
podman run -dt --restart always -e WORDPRESS_DB_HOST=localhost \ -e WORDPRESS_DB_USER=wordpress -e WORDPRESS_DB_PASSWORD=wordpress \ -e WORDPRESS_DB_NAME=wordpress --name wp --network wp-mysql \ wordpress:latest
Here the container will connect to the localhost system to communicate as there is nothing like a separate network device for communication between the containers.
To see the status of the pods and containers associated with it, use the command:
podman pod ps --ctr-names and podman ps
Using the podman, we can also create a YAML file for the Kubernetes so that the same application as the pod can be executed on top of Kubernetes too. To do so, use the command as
podman generate kube <pod-name> >> myPod.yaml
Now, we have two options to use this file, one to use it to deploy the wordpress application on top of Kubernetes or second to again use it as a pod for some kind of testing.
To use it as pod again use the command,
podman pod play kube myPod.yaml
Now two create pods using podman, there are further two ways as using two different kinds of network namespace that is rootless and rootful. To get more information go through the podman documentation or click here
If you have any doubts, please feel free to drop me a message. I will definitely try to resolve your doubts.