如何修改从现有版本创建的泊坞窗图像 [英] Howto modify an docker image that was created from an existing one

查看:134
本文介绍了如何修改从现有版本创建的泊坞窗图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据此 howto ,我根据现有的图像创建了新的图像。

现在我没有一个Docker文件,当容器启动时有事情发生

我不能改变 - 这是怎么样的。

Based on this howto i created a new image based on an existing one.
now i don´t have a Dockerfile and there are things happening, when the container starts
I cannot change - that´s how it looks to me.

有没有办法修改已在我使用的基本映像的Dockerfile中设置的内容?

Is there a way to modify things that have been setup in the Dockerfile of the base image I have used ?

例如:容器在启动时运行一个bash脚本,我想改变这个。

for example: the container runs a bash script when it starts, i want to change this.

推荐答案

要回答您的具体问题:容器在启动时运行一个bash脚本,我想更改此。假设您想要运行 /script.sh (部分图像)而不是默认值,则可以使用以下方式实例化容器:

To answer your specific q: "the container runs a bash script when it starts, i want to change this". Let's assume you want to run /script.sh (part of the image) instead of the default, you can instantiate a container using:

docker run --entrypoint /script.sh repo/image

如果 script.sh 不是图像的一部分,或者您不想每次使用明确指定它--entrypoint 如上所述,您可以准备一个包含并运行您自己的 script.sh 的图像:

If script.sh isn't part of the image and/or you prefer not having to specify it explicitly each time with --entrypoint as above, you can prepare an image that contains and runs your own script.sh:


  1. 创建一个空目录并复制或创建 script.sh

  2. 创建 Dockerfile ,其中包含以下内容:

  1. Create an empty directory and copy or create script.sh in it
  2. Create Dockerfile with following content:




    FROM repo/image
    ADD script.sh /
    ENTRYPOINT /script.sh




  1. docker build -t =myimage。

  2. docker run myimage

  1. docker build -t="myimage" .
  2. docker run myimage

注意:


  • 运行容器时(s tep 4),不再需要指定 - entrypoint ,因为我们在 Dockerfile 中默认。 li>
  • 真的很简单;没有必要注册到码头中心或任何这样的东西(虽然当然推荐在时间上; - )

  • When running the container (step 4), it's no longer necessary to specify --entrypoint since we have it defaulted in the Dockerfile.
  • It's really that simple; no need to sign up to docker hub or any such thing (although it's of course recommended in time ;-)

这篇关于如何修改从现有版本创建的泊坞窗图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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