将启动脚本添加到dockerfile [英] adding startup script to dockerfile
问题描述
我已经使用openjdk构建了docker镜像.
I have built my docker image using openjdk.
# config Dockerfile
FROM openjdk:8
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
# build image
docker build -t shantanuo/dbt .
使用此命令可以正常工作...
It is working as expected using this command...
docker run -p 8081:8080 -it shantanuo/dbt
登录后,我必须运行此命令...
Once I log-in, I have to run this command...
sh bin/startup.sh
我的问题:是否可以将启动命令添加到dockerfile?我尝试将这一行添加到我的dockerfile中.
My Question: Is it possible to add the startup command to dockerfile? I tried adding this line in my dockerfile.
CMD ["sh", "bin/startup.sh"]
但是在构建映像之后,我无法使用-d参数启动容器.
But after building the image, I can not use -d parameter to start the container.
推荐答案
您可以使用 entrypoint 运行启动脚本.在入口点,您可以指定您的自定义脚本,然后运行catlina.sh.示例:
You can use the entrypoint to run the startup script. In the entrypoint you can specify yoour custom script and then run catlina.sh. Example:
ENTRYPOINT "bin/startup.sh && catalina.sh run"
这将运行您的启动脚本,然后启动您的tomcat服务器.它不会退出容器.
This will run your startup script and then start your tomcat server. It wont exit the container.
这篇关于将启动脚本添加到dockerfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!