When it comes to container technology, everyone usually thinks of Docker. Docker is indeed a very popular container technology. Recently upgraded CentOS 8
, and found that it has another container technology Podman built-in, why does the official bless Podman? In fact, Podman is also developed by RedHat, and its own operating system naturally needs to support its own container technology. Today we're going to experience a Podman and see how amazing it is!
SpringBoot actual e-commerce project mall (50k+star) address: https://github.com/macrozheng/mall
Introduction to Podman
Podman is an open source project, available on Github at 12k+Star
and available on most Linux platforms. Podman is a daemonless container engine for developing, managing and running OCI (Open Container Initiative) containers and container images on Linux systems. Podman provides a command line tool compatible with Docker, you can simply alias the docker
command to podman
and use it, so if you know Docker, you can easily get started with Podman.
Installation starts
CentOS 8
has built-in Podman, you need to install it byCentOS 7
under 0621d7e30d58a1.
CentOS 7
can use the yum command to install Podman;
yum -y install podman
- After the installation is successful, use the following command to start the podman service.
systemctl start podman
use
Next, we will run Nginx, MySQL and SpringBoot applications in Podman, you can experience the difference between it and Docker.
- Download the Nginx image with the following command:
podman pull nginx:1.10
- When using Podman to download images, we can choose different image sources, and choosing to download from
docker.io
means downloading from DockerHub;
- Since the Podman container does not have permission to access the host's file system by default, when you want to mount the directory, you need to use
--privileged
to enable the permission. You can use the following command to run the nginx container, which is basically the same as docker;
podman run -p 80:80 --name nginx \
--privileged \
-v /mydata/nginx/html:/usr/share/nginx/html \
-v /mydata/nginx/logs:/var/log/nginx \
-d nginx:1.10
- After the operation is successful, put our
mall learning tutorial front-end project into
/mydata/nginx/html
to access it normally;
- Running a MySQL container is basically the same as using Docker, you can run it with the following command;
podman run -p 3306:3306 --name mysql \
--privileged \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7
- You can enter the mysql container and view database information through the following commands;
# 进入mysql容器
podman exec -it mysql /bin/bash
# 登录mysql
mysql -proot -uroot
# 查看所有数据库
show databases;
- I feel that Podman is basically the same as Docker, like a Docker with a new skin;
- Let's try running a SpringBoot application in Podman. First download the Docker image, which has been uploaded to DockerHub:
docker pull macrodocker/mall-tiny-boot:latest
- Run the SpringBoot application. If you want to use the
--link
option to connect to the mysql container, unfortunately Podman does not support it, so you can only use IP to access the mysql service;
podman run -p 8088:8088 --name mall-tiny-boot \
--privileged \
-e spring.datasource.url='jdbc:mysql://192.168.3.106:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai' \
-v /etc/localtime:/etc/localtime \
-v /mydata/app/mall-tiny/logs:/var/logs \
-d macrodocker/mall-tiny-boot:latest
- After running successfully, you can access the Swagger page of the SpringBoot application, and the access address: http://192.168.3.106:8088/swagger-ui/
- Use the
podman ps
command to view all running containers;
- Use the
podman images
command to view all downloaded images;
- If you do not have Docker installed and enter the docker command, you will be prompted to install the
podman-docker
plug-in, which will directly convert the docker command to podman. Do you want to completely replace docker?
Visual management
The built-in visual management tool Cockpit of CentOS 8
has built-in Podman support, you can use it directly. For details, please refer to Cockpit usage tutorial .
- Open
podman container management, you can view all running containers and downloaded images;
- You can also view container logs in real time, restart, stop or delete containers;
- You can also directly enter the container to execute commands, such as viewing the database in the mysql container;
- Mirror download can also be performed directly;
- You can also run containers through images, which is quite convenient to use.
Podman VS Docker
The comparison of various aspects of Podman and Docker can refer to the following table.
Podman | Docker | |
---|---|---|
Architecture | No daemon, can run the container under the user who started the container | Use a daemon to create images and run containers |
Safety | Allow containers to use rootless privileges | The daemon has root privileges |
run the container | Need another tool to manage services and support running of background containers | Manage and run containers with a daemon |
build image | Need assistance from container image generator Buildah | You can build your own container images |
idea | Adopt a modular approach, relying on specialized tools for specific tasks | A stand-alone, powerful tool |
use | Compatible with most Docker commands, there are special docker compatible plugins | use your own command |
Summarize
I experienced a Podman today, and it is indeed very similar to Docker. It feels like the main difference between Podman and Docker is whether daemons are used to manage containers and their philosophy. Docker emphasizes all in one
and is committed to becoming a powerful tool, while Podman emphasizes modularity, which is assisted by other tools to complete specific tasks. Docker and Podman are both excellent container engines. If Docker is already used in your project, there is no need to replace it with Podman. If your project is just starting, you can consider Podman when selecting technologies.
project address
https://github.com/containers/podman
This article GitHub https://github.com/macrozheng/mall-learning has been included, welcome everyone to Star!
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。