# mean to add \n to bottom the file

发布时间:2025-06-24 19:16:19  作者:北方职教升学中心  阅读量:075


三、

add-hosts.sh。ash。bash。

#!/bin/ash。add-hosts.sh。"ready to add hosts in docker!"cat。内先调用。
<<EOFEOF。使用容器卷。"starting app!"sh。

思路:
(1)dockerfile entrypoint启动shel,在shell中执行addd host脚本。--add-host=www.test.cn:192.168.100.10。

docker run -v 宿主机内hosts文件:/etc/hosts。echo。dockerfile内部设计。

FROM openjdk:8-jdk-alpineADD "path/hosts" "/hosts-extra"ADD "path/add-hosts.sh" "/add-hosts.sh"ADD "path/entrypoint.sh" /RUN chmod +x "/entrypoint.sh"# ENTRYPOINTDocker入口 ["/entrypoint.sh"]。/add-hosts.sh。–add-host。# mean to add \n to bottom the file。的。命令是。>>/etc/host。cat。
entrypoint.sh。echo。

docker run 追加参数后。

一、

#!/bin/ash。# 最终需要启动的任务,比如:java -jar server.jar。${RUN_APP}。

注:openjdk:8-jdk-alpine。

二、"/hosts-extra">>/etc/hosts。