将图像添加到我的Base Docker Image(Add Image to my Base Docker Image)

编程入门 行业动态 更新时间:2024-10-25 08:24:31
图像添加到我的Base Docker Image(Add Image to my Base Docker Image)

我有一个运行CentOS 6.5的docker base映像。 此图像保存在我的计算机上。 我找不到任何有关如何在此基本图像中添加更多图像的内容。 所以例如我有CentOS6.5的这个基本图像,我需要添加postgresql 9.3,以及php这个基本图像。 有没有一种方法,一旦你已经有一个基本图像,添加更多的包也基本图像?

I have a docker base image that runs CentOS 6.5. This image is saved on my computer. I could not find anything that talks about how to add more images into this base image. So for example I have this base image of CentOS6.5, I need too add postgresql 9.3, and php too this base image. Is there a way once you already have a base image made, to add more packages too that base image?

最满意答案

这就是Docker文件的全部目的:在图像之上构建一些东西。

创建dockerfile 构建新映像并使用docker build -t <tag> <path/to/build/context> 然后,如果要共享它,请将其推送到您的私人注册表或docker hub以使其可以访问( docker push <tag> )。

步骤2的构建上下文是Dockerfile的父目录。 例如,如果您在dockerfile所在的目录中运行该命令,则它将是docker docker build -t <tag> . 。

That's the whole purpose of the Docker file : build something on top of an image.

Create your dockerfile Build the new image and tag it with docker build -t <tag> <path/to/build/context> Then if you want to share it, push it to your private registry or to the docker hub to make it world accessible (docker push <tag>).

The build context of step 2 is the parent directory of your Dockerfile. For instance if you run the command in the directory where your dockerfile is it would be docker build -t <tag> ..

更多推荐

本文发布于:2023-08-04 21:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1422005.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   Base   Docker   Image   Add

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!