gpt4 book ai didi

docker - Docker创建独立镜像

转载 作者:行者123 更新时间:2023-12-02 19:08:32 27 4
gpt4 key购买 nike

Hy,我从Docer Hub的debian:jessie镜像之上为docker构建了一个小镜像。
首先,我从Docker Hub获得了debian:jessie:

docker pull debian:jessie

然后,我用bash开始此图像:
docker run -it debian:jessie

然后我安装了我的东西ssh服务器并对其进行配置。
接下来,从第二个shell提交更改:
docker commit <running container id> debian-sshd

现在我有两个图像:

debian:jessie和debian-sshd

如果我现在想删除debian:jessie,则docker告诉我我无法删除它,因为它具有child-images(debian-sshd)

Is There a way I can make debian-sshd an independent image?

最佳答案

Most Dockerfiles start from a parent image. If you need to completely control the contents of your image, you might need to create a base image instead. Here’s the difference:

  • A parent image is the image that your image is based on. It refers to the contents of the FROM directive in the Dockerfile. Each subsequent declaration in the Dockerfile modifies this parent image. Most Dockerfiles start from a parent image, rather than a base image. However, the terms are sometimes used interchangeably.

  • A base image either has no FROM line in its Dockerfile, or has FROM scratch.



引用 docs之后,我想说图像是由图层组成的,并且由于您的图像是基于 debian:jessie的,因此 debian-sshd的一层是debian:jessie图像。如果您想要独立的镜像,请从头开始构建。

除此之外,所有docker镜像都是开源的,因此您可以浏览dockerfile并对其进行修改以适合您的需求。另外,如果您想要自己的基本镜像,则可以从头开始构建。

关于docker - Docker创建独立镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45086033/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com