Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The first try of podman-compare with docker

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Podman First Test-vs. Docker 1, What is Docker?

Docker is an open source application container engine, a wrapper for Linux containers, Docker provides an easy-to-use container interface that allows developers to package their applications and dependencies into a portable container and then publish them to any popular Linux machine. Containers are completely sandboxed and do not interface with each other.

2 What is Podman?

Podman is an open-source container runtime project available on most Linux platforms. Podman provides functionality very similar to Docker. As mentioned earlier, it does not require any daemons to run on your system, and it can also run without root privileges.

Podman can manage and run any container and container image compliant with the OCI (Open Container Initiative) specification. Podman provides a Docker-compatible command-line front end to manage Docker images.

Podman official website address: podman.io/Podman Project address: https://github.com/containers/libpod3, Podman and docker difference? Docker needs to run a daemon on our system, while podman doesn't need to start containers differently:

Docker cli interacts with Docker Engine via API to tell it I want to create a container, and Docker Engine calls OCI container runtime(runc) to start a container. This means that the process of the container will not be the child process of Docker CLI, but the child process of Docker Engine.

Podman interacts directly with OCI container runtime(runc) to create containers, so container process is directly podman's child process. Docker has docker daemon, so docker startup containers support--restart policy, but podman does not support, if this problem does not exist in k8s, we can set pod restart policy, in the system we can write systemd service to complete the self-startup docker needs to use root user to create containers, but podman does not need 4, podman installation 4.1, Arch Linux & Manjaro Linuxsudo pacman -S podman 4.2, Fedora, Centossudo yum -y install podman 4.3, Gentousudo emergence app-emulation/libpod4.4, MacOSbrew cask install podman5, Podman CLI Introduction

87% of the commands in Podman CLI are the same as DOcker CLI. The official gives such an example alias docker=podman, so people who often use DOcker CLI use podman very quickly.

Run a container podman run -dt -p 80:80 --name nginx -v /data:/data -e NGINX_VERSION=1.16 nginx:1.16.0 List all current containers # podman ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES19f105d5dc1e docker.io/library/nginx:1.16.0 nginx -g daemon o... 2 minutes ago Up 2 minutes ago 0.0.0.0:80->80/tcp nginx View a mirror message # podman inspect nginx| grep -i "ipaddress" "SecondaryIPAddresses": null, "IPAddress": "10.88.0.110", view the logs of container runs podman logs nginx View running container resource usage # podman top nginxUSER PID PPID %CPU ELAPSED TTY TIME COMMANDroot 1 0 0.000 5m26.420969043s pts/0 0s nginx: master process nginx -g daemon off;nginx 6 1 0.000 5m26.421085502s pts/0 0s nginx: worker process# podman stats nginxID NAME CPU % MEM USAGE / LIMIT MEM % NET IO BLOCK IO PIDS19f105d5dc1e nginx -- 2.036MB / 1.893GB 0.11% 978B / 10.55kB -- / -- 2 Migration containers

Podman supports migrating containers from one machine to another.

First, checkpoint the container on the source machine and package it to the specified location.

$ sudo podman container checkpoint -e /tmp/checkpoint.tar.gz$ scp /tmp/checkpoint.tar.gz :/tmp

Second, the container is restored on the target machine using the packaged file transferred from the source machine.

$ sudo podman container restore -i /tmp/checkpoint.tar.gzpodman's program how to set up self-startup

Since Podman no longer uses daemon management services, it is not possible to implement the automatic restart of containers through daemons. So if you want to achieve automatic boot restart container, and how to achieve it?

The method is simple, most systems now use Systemd as a daemon management tool. Here we can use Systemd to implement Podman boot restart container, here we just started nginx as an example.

Create a Systemd service profile.

$ vim /etc/systemd/system/nginx_podman.service[Unit]Description=Podman Nginx ServiceAfter=network.targetAfter=network-online.target[Service]Type=simpleExecStart=/usr/bin/podman start -a nginxExecStop=/usr/bin/podman stop -t 10 nginxRestart=always[Install]WantedBy=multi-user.target

Next, enable this Systemd service

$ sudo systemctl daemon-reload$ sudo systemctl enable nginx_podman.service$ sudo systemctl start nginx_podman.service

After that, every time the system restarts, Systemd will automatically start the container corresponding to this service. After the container dies, it will also start this container. We can use the following example to test it.

Make a sleep 30 docker package, this container can only last for 30s at a time

$ vim DockerfileFROM busybox:latestCMD ["sh","-c","sleep 30"]

Then set the startup auto-start as described above

The container launched under Podman is the child process of Podman under demonstration

We just started an nginx podman and now let's take a look at his progress.

# ps -ef | grep [n]ginxroot 19368 19359 0 11:38 pts/0 00:00:00 nginx: master process nginx -g daemon off;101 19381 19368 0 11:38 pts/0 00:00:00 nginx: worker process

Then look at this nginx parent process is that

# ps -ef | grep 19359root 19359 1 0 11:38 ? 00:00:00 /usr/libexec/podman/conmon 。。。。

So that confirms what I said above.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report