我想在运行时通过docker撰写在configuration文件中填充一个条目
我有一个容器安装tomcat,里面有应用程序configuration文件。 我想在运行时在其中填充一个值。 (在此之前,我不知道在构build图像时不能填充的值)
我正在用docker-compose调用服务,并且我希望configuration文件中的值被replace为我提供给docker的值作为参数
类似docker的东西 – 通过docker组成“up -e”值在运行时间“
URL for server SERVERADD=https://{{value at run time via docker compose}}/{{index}}
我可以用环境variables或任何其他方式友好地build议!
这通常是在图像内置的ENTRYPOINT
或CMD
脚本中完成的。
该脚本检查环境variables,是否需要replace或其他工作,然后继续像以前一样运行该命令。
#!/bin/sh if [ -n "$SOME_ENV" ]; then sed -i '' -e 's/^param=.*/param='"$SOME_ENV"'/' /etc/file.conf fi exec "$@"
该脚本需要添加到图像,Dockerfile可以是:
FROM whatever COPY docker-entrypoint.sh /entrypoint.sh ENTRYPOINT [ "/entrypoint.sh" ] CMD [ "run_server", "-o", "option" ]