加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 运营中心 > 网站设计 > 教程 > 正文

Docker允许构建、运行、拉

发布时间:2021-05-25 20:57:19 所属栏目:教程 来源:互联网
导读:副标题#e# 对于已经用了很久docker的人,可能需要花费些功夫去说服自己去考虑转换使用不同的工具。 Docker是一个庞大单一的工具,它尝试做任何事,但通常没有用最好的方法去做。我们最好选择只做一件事,但确实做得很好的专门工具。如果害怕切换不同的工具

它的功能遵循与Podman相同的路线,是无守护程序和无根的,并且可以生成OCI兼容的镜像,可以确保你的镜像与Docker构建镜像的运行方式相同。除此之外,Buildah还提供了对图像层的更精细的控制,允许将许多更改提交到单个层中。与Docker相比,Buildah构建的镜像是特定于用户的,因此只能列出自己构建的镜像。

那么,既然Buildah已经包含在podman CLI中,为什么还要使用单独的Buildah CLI?原因在于,buildahcli是podman build中包含的命令的超集,可能不需要接触buildah CLI,但是通过使用它,可能还会发现一些额外有用的特性。

可以看一个小型过程展示:

~ $ buildah bud-f Dockerfile . 

             ~ $ buildah from alpine:latest  # Create starting container - equivalentto "FROM alpine:latest" 

             Getting image source signatures 

             Copying blobdf20fa9351a1 done  

             Copying configa24bb40132 done  

             Writing manifest toimage destination 

             Storing signatures 

             alpine-working-container  # Name of the temporary container 

             ~ $ buildah runalpine-working-container -- apk add --update --no-cache python3  # equivalent to "RUN apk add--update --no-cache python3" 

             fetch 

             fetch 

             ... 

             ~ $ buildahcommit alpine-working-container my-final-image # Create final image 

             Getting image source signatures 

             Copying blob50644c29ef5a skipped: already exists  

             Copying blob362b9ae56246 done  

             Copying config1ff90ec2e2 done  

             Writing manifest toimage destination 

             Storing signatures 

             1ff90ec2e26e7c0a6b45b2c62901956d0eda138fa6093d8cbb29a88f6b95124c 

             ~# buildah images 

             REPOSITORY               TAG     IMAGE ID      CREATED         SIZE 

             localhost/my-final-imagelatest  1ff90ec2e26e  22 seconds ago  51.4 MB 

从上面的脚本可知,可以仅使用buildah bud来构建镜像,其中bud代表使用Dockerfile进行构建,但是还可以使用更多的脚本化方法,通过Buildahs的from、run和copy,这与Dockerfile中的命令等效。

接下来是Google的Kaniko。Kanik也与Dockerfile构建容器镜像,类似于Buildah,它也不需要守护进程。其与Buildah的主要区别在于,Kaniko更专注于在Kubernetes中构建镜像。

Kanik使用gcr.io/kaniko-project/executor作为镜像运行,这对于Kubernetes有意义,但对于本地构建而言并不方便,且无法达到目的,因为需要使用Docker运行Kaniko镜像来构建新镜像。

话虽如此,如果正在寻找用于在Kubernetes集群中构建镜像的工具(例如在CI/CD管道中),无守护进程并且(也许)更安全,Kaniko可能是一个不错的选择。

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读