如何从Docker映像中删除ENV设置 [英] how to remove an ENV setting from a docker image

查看:624
本文介绍了如何从Docker映像中删除ENV设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个设置了HOME和PATH的docker镜像:

I have a docker image which sets HOME and PATH:

[{
  ...
  "config": {
    "HOME=/",
  }
  ...

我知道我可以替换它,但是可以将其删除(并使用常规的bash配置文件设置代替)。我不希望通过破解shell配置文件来覆盖它。

I know I can replace it, but is it possible to remove it (and let the normal bash profile settings be used instead). I'd prefer not to hack the shell profile files to override it.

推荐答案

您只需执行手动提交即可。

You can simply perform a manual commit.

此操作在Dockerfile中不可用,但可以手动完成。

This operation is not available within the Dockerfile, but can be done manually.

执行 docker inspect< image> ,您可以检索用于创建此图像的容器的ID。

When doing docker inspect <image>, you can retrieve the ID of the container that has been used in order to create this image.

您然后可以执行 docker commit< container id> <新映像名称> ,所有ENV和其他配置都将被刷新。

You can do then docker commit <container id> <new image name> and all the ENV and other config will get flushed.

如果容器已删除,则可以运行图片 docker run -d< image> <任何命令,然后提交生成的容器。

If the container has been removed, you can run the image docker run -d <image> <any command, and then commit the resulting container.

如果要保留某些配置​​,可以使用 docker commit -run'{}'<容器ID> <新图片名称> 语法。 cf http://docs.docker.io/en/latest/commandline/command / commit / 了解更多信息。

If you want to keep some of the configuration, you can use the docker commit -run '{}' <container id> <new image name> syntax. Cf http://docs.docker.io/en/latest/commandline/command/commit/ for more info.

这篇关于如何从Docker映像中删除ENV设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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