【发布时间】:2021-11-18 06:19:34
【问题描述】:
我想在“docker build”期间更新我的/etc/hosts 文件。
我在 Dockerfile 中添加了以下行,但它既没有更新 /etc/hosts 文件也没有给出任何错误。
RUN echo "192.168.33.11 mynginx" >> /etc/hosts
我需要更新/etc/hosts。有人可以就此提出建议吗?
【问题讨论】:
-
你在使用 boot2docker 来执行你的 docker build 吗?
-
不,我使用的是 docker 1.8 的 Linux 版本。
-
当您将镜像作为容器运行时,它的 /etc/hosts 是否不变?还是您指的是您的 Linux 主机 /etc/hosts?
-
在 docker build 映像成功构建期间。但是当我使用相同的映像运行容器并检查 /etc/hosts 文件时,没有更改。
标签: docker dockerfile hosts