Docker创建独立映像 [英] Docker create independent image

查看:70
本文介绍了Docker创建独立映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Hy i build a little image for docker on top of the debian:jessie image form the Docer Hub. First i got debian:jessie from Docker Hub:

docker pull debian:jessie

然后我以bash开头此图像:

Then I startet this image with a bash:

docker run -it debian:jessie

然后我安装了我的东西ssh服务器并对其进行配置。
接下来,从第二个shell提交更改:

Then I installed my stuff e.g. ssh server and configured it. Next from a second shell, i commitet the changes:

docker commit <running container id> debian-sshd

现在我有两个图像:

debian:jessie和debian-sshd

debian:jessie and debian-sshd

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

If i now want to delete debian:jessie, docker tells me i can't delete this because it has child-images(debian-sshd)


有没有办法使debian-sshd成为独立的映像?

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


推荐答案


大多数Dockerfiles从父映像开始。如果您需要完全由
控制图像的内容,则可能需要创建基本的
图像。区别在于:

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:


  • 父图像是图像所基于的图像。它引用Dockerfile中FROM指令的内容。 Dockerfile中的每个
    后续声明都会修改此父映像。
    大多数Dockerfiles从父映像开始,而不是基本映像。
    但是,这些术语有时可以互换使用。

  • 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.

基本映像要么在其Dockerfile中没有FROM行,要么具有FROM scratch。 p>

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

引用自文档,我想说图像是由图层组成的,并且由于您的图像基于 debian:jessie debian-sshd 的一层是debian:jessie映像。如果您想要独立的映像,请从头开始构建。

Having quoted from docs, I would say that images are made up of layers, and since you have based your image on debian:jessie, one of the layers of debian-sshd is the debian:jessie image. If you want your independent image, build from scratch.

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

Other then that, all docker images are open source, so you can browse the dockerfile and modify it to suit your needs. Also, you could build from scratch if you want your own base image.

这篇关于Docker创建独立映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆