英文:
Adding script in Docker File that starts when the container starts
问题
我一直在尝试为我的Java应用编写Docker文件。我该如何在Docker文件中添加"start_service.sh",以便在Docker容器启动运行时执行该文件。
英文:
I have been trying to write the docker file for my Java application. How i can add start_service.sh in Docker file which will execute when the docker container starts running.
答案1
得分: 0
可以使用 ENTRYPOINT
Docker 命令来实现此目的,它将在容器启动时运行脚本。
示例:
FROM ...
...
COPY start_service.sh start_service.sh
ENTRYPOINT ["sh", "./start_service.sh"]
在这种情况下,脚本 start_service.sh
将在容器启动时执行。
英文:
You can use ENTRYPOINT
docker command for this purpose, it will run the script on container start.
Example:
FROM ...
...
COPY start_service.sh start_service.sh
ENTRYPOINT ["sh", "./start_service.sh"]
In this case, the script start_service.sh
will be executed on the container start.
答案2
得分: 0
这可能有助于解决问题
...
COPY start_service.sh start_service.sh
ENTRYPOINT ["./start_service.sh"]
...
https://docs.docker.com/engine/reference/builder/
英文:
this may help u solve the problem
...
COPY start_service.sh start_service.sh
ENTRYPOINT ["./start_service.sh"]
...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论