【问题标题】:What is the best way to append to /etc/hosts within Dockerfile在 Dockerfile 中附加到 /etc/hosts 的最佳方法是什么
【发布时间】:2015-12-14 23:31:59
【问题描述】:

不幸的是,Docker 不会在 Dockerfiles 中的 RUN 命令之间持久化 /etc/hosts 文件

请推荐在 Dockerfile 中追加到 /etc/hosts 的最佳方式

【问题讨论】:

    标签: docker dockerfile docker-compose docker-registry dockerhub


    【解决方案1】:

    最好不要这样做,主要是因为您将图像绑定到您的网络。相反,使用 --add-host 标志到 docker run 添加条目,例如:

    docker run --add-host test:127.0.0.1 nginx
    

    【讨论】:

    猜你喜欢
    • 2013-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-09
    • 2011-11-21
    • 1970-01-01
    相关资源
    最近更新 更多