入口点是秘密。
你有两个解决方案:
两种解决方案都具有相同的 Dockerfile
From java:x
COPY jar ...
COPY myentrypoint /
ENTRYPOINT ["bash", "/myentrypoint"]
但不一样的ENTRYPOINT(myentrypoint)
解决方案 A - 入口点:
#!/bin/bash
# if the env var DB_URL is not empty
if [ ! -z "${DB_URL}" ]; then
echo "url=${DB_URL}" >> App/bin/config/application.properties
fi
# do the same for other props
#...
exec call-the-main-entry-point-here $@
要从此解决方案创建容器:
docker run -it -e DB_URL=jdbc:postgresql://localhost:5432/sakila myimage
解决方案 B - 入口点:
#!/bin/bash
# if /etc/java/props.d/ is a directory
if [ -d "/etc/java/props.d/" ]; then
cat /etc/java/props.d/*.properties
awk '{print $0}' /etc/java/props.d/*.properties >> App/bin/config/application.properties
fi
#...
exec call-the-main-entry-point-here $@
要从此解决方案创建容器:
docker run -it -v ./folder-has-props-files:/etc/java/props.d myimage