当前位置:   article > 正文

podman部署及应用_podman安装k8s

podman安装k8s

podman部署及应用

目录

podman部署及应用

podman介绍

podman部署

配置加速器

podman命令

podman介绍

Podman 是一个开源的容器运行时项目,可在大多数 Linux 平台上使用。Podman 提供与 Docker 非常相似的功能。正如前面提到的那样,它不需要在你的系统上运行任何守护进程,并且它也可以在没有 root 权限的情况下运行。

Podman 可以管理和运行任何符合 OCI(Open Container Initiative)规范的容器和容器镜像。Podman 提供了一个与 Docker 兼容的命令行前端来管理 Docker 镜像。[3]

Podman 不足之处: 
因为没有类似 docker daemon 守护进程,所以不支持 –restart 策略,不过使用 k8s 编排就不存在这个问题 
Centos8 去除了 Docker 作为默认的容器化管理工具,使用 Podman、Buildah、Skopeo 进行了替换。

podman部署

 
  1. [root@localhost ~]# dnf install -y podman
  2. Failed to set locale, defaulting to C.UTF-8
  3. CentOS Stream 8 - AppStream 2.1 kB/s | 4.4 kB 00:02
  4. CentOS Stream 8 - AppStream 4.4 MB/s | 24 MB 00:05
  5. CentOS Stream 8 - BaseOS 381 B/s | 3.9 kB 00:10
  6. CentOS Stream 8 - BaseOS 3.0 MB/s | 25 MB 00:08
  7. CentOS Stream 8 - Extras 5.8 kB/s | 2.9 kB 00:00
  8. Dependencies resolved.
  9. =================================================================================================================================================================================================
  10. Package Architecture Version Repository Size
  11. =================================================================================================================================================================================================
  12. Installing:
  13. podman x86_64 2:4.0.2-1.module_el8.7.0+1106+45480ee0 appstream 13 M
  14. Upgrading:
  15. libsemanage x86_64 2.9-8.el8 baseos 168 k
  16. policycoreutils x86_64 2.9-19.el8 baseos 374 k

配置加速器

 
  1. [root@localhost ~]# cd /etc/containers/
  2. [root@localhost containers]# ls
  3. certs.d policy.json registries.conf.d storage.conf
  4. oci registries.conf registries.d
  5. [root@localhost containers]# vim registries.conf
  6. unqualified-search-registries = ["docker.io"]
  7. [[registry]]
  8. prefix = "docker.io"
  9. location = "https://4e3uv4d0.mirror.aliyuncs.com"
  10. //查看加速器
  11. [root@localhost containers]# podman info
  12. .....................
  13. Blocked: false
  14. Insecure: false
  15. Location: https://4e3uv4d0.mirror.aliyuncs.com
  16. MirrorByDigestOnly: false
  17. Mirrors: null
  18. Prefix: docker.io
  19. ..............................

podman命令

 
  1. [root@localhost ~]# podman pull httpd //拉取镜像
  2. ✔ docker.io/library/httpd:latest
  3. Trying to pull docker.io/library/httpd:latest...
  4. Getting image source signatures
  5. Copying blob 80e368ef21fc done
  6. Copying blob 4340e7be3d7f done
  7. Copying blob aed046121ed8 done
  8. Copying blob 80cb79a80bbe done
  9. Copying blob 1efc276f4ff9 done
  10. Copying config f2a976f932 done
  11. Writing manifest to image destination
  12. Storing signatures
  13. f2a976f932ec6fe48978c1cdde2c8217a497b1f080c80e49049e02757302cf74
  14. [root@localhost ~]# podman images //查看系统中的所有镜像
  15. REPOSITORY TAG IMAGE ID CREATED SIZE
  16. docker.io/library/httpd latest f2a976f932ec 12 days ago 149 MB
  17. [root@localhost ~]# podman diff httpd //检查映像文件系统的更改
  18. C /usr
  19. C /usr/local
  20. C /usr/local/bin
  21. A /usr/local/bin/httpd-foreground
  22. [root@localhost ~]# podman image history httpd 显示指定镜像的历史记录
  23. ID CREATED CREATED BY SIZE COMMENT
  24. f2a976f932ec 12 days ago /bin/sh -c #(nop) CMD ["httpd-foreground"] 0 B
  25. <missing> 12 days ago /bin/sh -c #(nop) EXPOSE 80 0 B
  26. <missing> 12 days ago /bin/sh -c #(nop) COPY file:c432ff61c4993e... 3.58 kB
  27. <missing> 12 days ago /bin/sh -c #(nop) STOPSIGNAL SIGWINCH 0 B
  28. <missing> 12 days ago /bin/sh -c set -eux; savedAptMark="$(apt... 60.4 MB
  29. <missing> 12 days ago /bin/sh -c #(nop) ENV HTTPD_PATCHES= 0 B
  30. <missing> 12 days ago /bin/sh -c #(nop) ENV HTTPD_SHA256=eb397f... 0 B
  31. <missing> 12 days ago /bin/sh -c #(nop) ENV HTTPD_VERSION=2.4.54 0 B
  32. <missing> 12 days ago /bin/sh -c set -eux; apt-get update; apt... 5.1 MB
  33. <missing> 12 days ago /bin/sh -c #(nop) WORKDIR /usr/local/apache2 0 B
  34. <missing> 12 days ago /bin/sh -c mkdir -p "$HTTPD_PREFIX" && ch... 3.07 kB
  35. <missing> 12 days ago /bin/sh -c #(nop) ENV PATH=/usr/local/apa... 0 B
  36. <missing> 12 days ago /bin/sh -c #(nop) ENV HTTPD_PREFIX=/usr/l... 0 B
  37. <missing> 12 days ago /bin/sh -c #(nop) CMD ["bash"] 0 B
  38. <missing> 12 days ago /bin/sh -c #(nop) ADD file:0eae0dca665c704... 83.9 MB
  39. [root@localhost ~]# podman image inspect httpd //显示镜像的配置
  40. [
  41. {
  42. "Id": "f2a976f932ec6fe48978c1cdde2c8217a497b1f080c80e49049e02757302cf74",
  43. "Digest": "sha256:343452ec820a5d59eb3ab9aaa6201d193f91c3354f8c4f29705796d9353d4cc6",
  44. "RepoTags": [
  45. "docker.io/library/httpd:latest"
  46. ],
  47. "RepoDigests": [
  48. "docker.io/library/httpd@sha256:343452ec820a5d59eb3ab9aaa6201d193f91c3354f8c4f29705796d9353d4cc6",
  49. "docker.io/library/httpd@sha256:98778663b10c3952e9d7dd8a10e1ca2a8ce31f11b5f0ff9d7b3b36ddb8201db8"
  50. ],
  51. ······
  52. "NamesHistory": [
  53. "docker.io/library/httpd:latest"
  54. ]
  55. }
  56. ]
  57. [root@localhost ~]# podman image list //列出本地存储的镜像
  58. REPOSITORY TAG IMAGE ID CREATED SIZE
  59. docker.io/library/httpd latest f2a976f932ec 12 days ago 149 MB
  60. [root@localhost ~]# podman image rm httpd //删除镜像
  61. Untagged: docker.io/library/httpd:latest
  62. Deleted: f2a976f932ec6fe48978c1cdde2c8217a497b1f080c80e49049e02757302cf74
  63. [root@localhost ~]# podman images
  64. REPOSITORY TAG IMAGE ID CREATED SIZE
  65. [root@localhost ~]# podman image save busybox > busybox.tar //将镜像保存到本地
  66. [root@localhost ~]# ls
  67. anaconda-ks.cfg busybox.tar http.tar
  68. [root@localhost ~]# podman image load < busybox.tar //从tar存档加载镜像
  69. Getting image source signatures
  70. Copying blob 084326605ab6 skipped: already exists
  71. Copying config 7a80323521 done
  72. Writing manifest to image destination
  73. Storing signatures
  74. Loaded image(s): docker.io/library/busybox:latest
  75. [root@localhost ~]# podman image list
  76. 'REPOSITORY TAG IMAGE ID CREATED SIZE
  77. docker.io/library/busybox latest 7a80323521cc 2 weeks ago 1.47 MB
  78. [root@localhost ~]# podman image prune //删除未使用的镜像
  79. WARNING! This command removes all dangling images.
  80. Are you sure you want to continue? [y/N] y
  81. [root@localhost ~]# podman image search busybox //搜索镜像
  82. INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
  83. docker.io docker.io/library/busybox Busybox base image. 2712 [OK]
  84. docker.io docker.io/rancher/busybox 0
  85. docker.io docker.io/ibmcom/busybox 0
  86. ······
  87. docker.io docker.io/busybox42/haraka-docker-centos CentOS Haraka build with spamassassin, redis... 1 [OK]
  88. docker.io docker.io/busybox42/nginx_php-docker-centos This is a nginx/php-fpm server running on Ce... 1 [OK]
  89. [root@localhost ~]# podman image tree busybox 以树格式打印镜像的图层层次结构
  90. Image ID: 7a80323521cc
  91. Tags: [docker.io/library/busybox:latest]
  92. Size: 1.468MB
  93. Image Layers
  94. └── ID: 084326605ab6 Size: 1.463MB Top Layer of: [docker.io/library/busybox:latest]

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
  

闽ICP备14008679号