年轻人谁还用Docker?
wptr33 2024-12-11 17:29 15 浏览
好吧,我其实想说的是podman :)
podman(Pod Manager)是一个由RedHat公司推出的容器管理工具,它的定位就是docker的替代品,在使用上与docker的体验类似。podman源于CRI-O项目,可以直接访问OCI的实现(如runC),流程比docker要短。
和Docker相比,podman无需root启动的守护进程,所以在安全性方面更胜一筹。
话不多说,我们直接来体验一把:
首先安装,以CentOS为例:
[root@test-vm001 ~]# yum -y install podman
检查一下版本:
[root@test-vm001 ~]# podman -v
podman version 2.0.5
查看一下支持的命令,和docker基本一致:
[root@test-vm001 ~]# podman --help
Manage pods, containers and images
Usage:
podman [flags]
podman [command]
Available Commands:
attach Attach to a running container
auto-update Auto update containers according to their auto-update policy
build Build an image using instructions from Containerfiles
commit Create new image based on the changed container
container Manage containers
cp Copy files/folders between a container and the local filesystem
create Create but do not start a container
diff Display the changes to the object's file system
events Show podman events
exec Run a process in a running container
export Export container's filesystem contents as a tar archive
generate Generate structured data based on containers and pods.
healthcheck Manage health checks on containers
help Help about any command
history Show history of a specified image
image Manage images
images List images in local storage
import Import a tarball to create a filesystem image
info Display podman system information
init Initialize one or more containers
inspect Display the configuration of object denoted by ID
kill Kill one or more running containers with a specific signal
load Load an image from container archive
login Login to a container registry
logout Logout of a container registry
logs Fetch the logs of one or more containers
manifest Manipulate manifest lists and image indexes
mount Mount a working container's root filesystem
network Manage networks
pause Pause all the processes in one or more containers
play Play a pod and its containers from a structured file.
pod Manage pods
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image from a registry
push Push an image to a specified destination
restart Restart one or more containers
rm Remove one or more containers
rmi Removes one or more images from local storage
run Run a command in a new container
save Save image to an archive
search Search registry for image
start Start one or more containers
stats Display a live stream of container resource usage statistics
stop Stop one or more containers
system Manage podman
tag Add an additional name to a local image
top Display the running processes of a container
unmount Unmounts working container's root filesystem
unpause Unpause the processes in one or more containers
unshare Run a command in a modified user namespace
untag Remove a name from a local image
version Display the Podman Version Information
volume Manage volumes
wait Block on one or more containers
Flags:
--cgroup-manager string Cgroup manager to use ("cgroupfs"|"systemd") (default "systemd")
--cni-config-dir string Path of the configuration directory for CNI networks (default "/usr/libexec/cni")
--conmon string Path of the conmon binary
-c, --connection string Connection to use for remote Podman service
--events-backend string Events backend to use ("file"|"journald"|"none") (default "file")
--help Help for podman
--hooks-dir strings Set the OCI hooks directory path (may be set multiple times) (default [/usr/share/containers/oci/hooks.d])
--identity string path to SSH identity file, (CONTAINER_SSHKEY)
--log-level string Log messages above specified level (debug, info, warn, error, fatal, panic) (default "error")
--namespace string Set the libpod namespace, used to create separate views of the containers and pods on the system
--network-cmd-path string Path to the command for configuring the network
-r, --remote Access remote Podman service (default false)
--root string Path to the root directory in which data, including images, is stored
--runroot string Path to the 'run directory' where all state information is stored
--runtime string Path to the OCI-compatible binary used to run containers, default is /usr/bin/runc
--storage-driver string Select which storage driver is used to manage storage of images and containers (default is overlay)
--storage-opt stringArray Used to pass an option to the storage driver
--syslog Output logging information to syslog as well as the console (default false)
--tmpdir string Path to the tmp directory for libpod state content.
Note: use the environment variable 'TMPDIR' to change the temporary storage location for container images, '/var/tmp'.
--url string URL to access Podman service (CONTAINER_HOST) (default "unix:/run/podman/podman.sock")
-v, --version Version of Podman
Use "podman [command] --help" for more information about a command.
搜索一下镜像,podman会去redhat和docker hub搜索镜像(省略了绝大多数输出):
[root@test-vm001 ~]# podman search httpd
redhat.com registry.access.redhat.com/rhscl/httpd-24-rhel7 Apache HTTP 2.4 Server 0
redhat.com registry.access.redhat.com/cloudforms46-beta/cfme-openshift-httpd CloudForms is a management and automation pl... 0
redhat.io registry.redhat.io/rhscl/httpd-24-rhel7 Apache HTTP 2.4 Server 0
docker.io docker.io/library/httpd The Apache HTTP Server Project 3318 [OK]
启动一个容器:
[root@test-vm001 ~]# podman run -dt -p 8080:8080/tcp registry.fedoraproject.org/f29/httpd
Trying to pull registry.fedoraproject.org/f29/httpd...
Getting image source signatures
Copying blob d77ff9f653ce done
Copying blob aaf5ad2e1aa3 done
Copying blob 7692efc5f81c done
Copying config 25c76f9dcd done
Writing manifest to image destination
Storing signatures
efe658b567ec3758524abe65248a7045374e4a15b9493d8885889cfffce8d407
查看一下运行的容器:
[root@test-vm001 ~]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
efe658b567ec registry.fedoraproject.org/f29/httpd:latest /usr/bin/run-http... 24 seconds ago Up 23 seconds ago 0.0.0.0:8080->8080/tcp reverent_austin
尝试访问一下容器提供的服务:
[root@test-vm001 ~]# curl http://localhost:8080
从输出结果可以看到容器已经运行起来了。
查看一下进程,发现httpd容器是podman的子进程:
[root@test-vm001 ~]# ps -ef | grep 8919
root 8919 1 0 07:34 ? 00:00:00 /usr/bin/conmon --api-vers...
1001 8930 8919 0 07:34 pts/0 00:00:00 httpd -D FOREGROUND
root 9290 5136 0 07:46 pts/0 00:00:00 grep --color=auto 8919
podman用来管理容器及pod,需要构建镜像的话,需要使用到buildah。此外还有操作远程仓库及镜像签名的工具skopeo,我们下次再说。
- 上一篇:Containerd和docker常用命令比较
- 下一篇:docker -k8s
相关推荐
- 「网络安全」JAVA代码审计——XXE外部实体注入
-
一、WEB安全部分想要了解XXE,在那之前需要了解XML的相关基础二、XML基础...
- Web前端面试题目及答案汇总(web前端面试题最新)
-
Web前端面试题目及答案汇总来源:极客头条以下是收集一些面试中经常会遇到的经典面试题以及自己面试过程中无法解决的问题,通过对知识的整理以及经验的总结,重新巩固自身的前端基础知识,如有错误或更好的答案,...
- 什么是脚本文件?与可执行文件有什么不同?
-
今天的内容是脚本文件和可执行文件是两种不同类型的计算机文件,它们在结构和执行方式上有显著区别。脚本文件:定义与特性...
- 20个实用Python运维脚本(收藏级)(python 运维工具)
-
系统环境:支持Linux(Ubuntu/CentOS/Debian)和Windows...
- 2026年前每个开发者都应该学习的技能
-
优秀开发者...
- Linux 如何每 5、10、15 或 30 分钟运行一次 Cron 作业?
-
在Linux系统中,Cron是一个强大的工具,用于自动化重复性任务。通过合理配置...
- Shell脚本编程进阶实战:从入门到高效自动化
-
Shell脚本编程进阶实战:从入门到高效自动化一、参数处理进阶:打造专业级CLI工具1.高级参数解析示例...
- 在Bash中按分隔符拆分字符串的方法
-
技术背景在Bash脚本编程中,经常会遇到需要按特定分隔符拆分字符串的需求,例如处理CSV文件、解析日志等。掌握字符串拆分的方法对于数据处理和脚本自动化非常重要。...
- 程序员用5分钟,把一个400多MB的苹果安装包削掉了187MB
-
丰色发自凹非寺量子位|公众号QbitAI前些日子,一个...
- 如何在 Windows 上编写批处理脚本
-
你知道如何使用命令提示符吗?如果这样做,您可以编写一个批处理文件。在最简单的形式中,批处理文件(或批处理脚本)是双击文件时执行的几个命令的列表。批处理文件一直回到DOS,但仍然适用于现代版本的Win...
- 一文搞懂shell脚本(shell脚本应用实战)
-
一文搞懂shell脚本1、shell脚本介绍什么是shell脚本...
- 一文讲清ShellScript脚本编程知识
-
摘要:本文详尽地讲述了ShellScript的基础内容,还有它在Linux系统里的运用情况,涵盖了它的基本语法、常用的命令以及高级的功能。ShellScript可是一种简单又非常实用的编...
- 在Bash脚本中获取自身所在目录的方法
-
技术背景在使用Bash脚本时,有时需要获取脚本自身所在的目录。比如,当脚本作为另一个应用程序的启动器时,需要将工作目录更改为脚本所在的目录,以便对该目录中的文件进行操作。然而,由于脚本的调用方式多样(...
- shell中如何确定脚本的位置?这篇文章告诉你
-
我想从同一个位置读取一些配置文件,如何确定脚本的位置?。这个问题的出现主要是由两个原因引发的:一是您希望将脚本的数据或配置进行外部化,因此需要一种方式来寻找这些外部资源;二是您的脚本需要对某些捆绑资源...
- bash shell 语法(bash命令用法)
-
下面是**Shell(Bash)语法的常用知识点总结**,适合初学者和日常脚本编写参考。内容涵盖变量、判断、循环、函数、重定向、正则、数组等常见用法。---#Shell(Bash)语法速查总结...
- 一周热门
-
-
C# 13 和 .NET 9 全知道 :13 使用 ASP.NET Core 构建网站 (1)
-
因果推断Matching方式实现代码 因果推断模型
-
git pull命令使用实例 git pull--rebase
-
面试官:git pull是哪两个指令的组合?
-
git 执行pull错误如何撤销 git pull fail
-
git pull 和git fetch 命令分别有什么作用?二者有什么区别?
-
git fetch 和git pull 的异同 git中fetch和pull的区别
-
git pull 之后本地代码被覆盖 解决方案
-
还可以这样玩?Git基本原理及各种骚操作,涨知识了
-
git命令之pull git.pull
-
- 最近发表
- 标签列表
-
- git pull (33)
- git fetch (35)
- mysql insert (35)
- mysql distinct (37)
- concat_ws (36)
- java continue (36)
- jenkins官网 (37)
- mysql 子查询 (37)
- python元组 (33)
- mybatis 分页 (35)
- vba split (37)
- redis watch (34)
- python list sort (37)
- nvarchar2 (34)
- mysql not null (36)
- hmset (35)
- python telnet (35)
- python readlines() 方法 (36)
- munmap (35)
- docker network create (35)
- redis 集合 (37)
- python sftp (37)
- setpriority (34)
- c语言 switch (34)
- git commit (34)