docker ENTRYPOINT上的多个命令 [英] Multiple commands on docker ENTRYPOINT

查看:721
本文介绍了docker ENTRYPOINT上的多个命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建自定义的tcserver docker映像。但是启动Web服务器和tomcat时遇到了一些问题。

据我了解,我应该使用ENTRYPOINT运行我想要的命令。

问题是,是否可以使用ENTRYPOINT运行多个命令?

还是应该创建一个小的bash脚本来全部启动?

I'm trying to build a custom tcserver docker image. But I'm having some problems starting the webserver and the tomcat.
As far as I understand I should use ENTRYPOINT to run the commands I want.
The question is, is it possible to run multiple commands with ENTRYPOINT?
Or should I create a small bash script to start all?

基本上我想做的是:

Basically what I would like to do is:

ENTRYPOINT /opt/pivotal/webserver/instance1/bin/httpdctl start && /opt/pivotal/webserver/instance2/bin/httpdctl start && /opt/pivotal/pivotal-tc-server-standard/standard-4.0.1.RELEASE/tcserver start instance1 -i /opt/pivotal/pivotal-tc-server-standard && /opt/pivotal/pivotal-tc-server-standard/standard-4.0.1.RELEASE/tcserver start instance2 -i /opt/pivotal/pivotal-tc-server-standard

但是我不知道这是否是一个好习惯,或者甚至行得通。

But I don't know if that is a good practice or if that would even work.

推荐答案

如果要在入口点运行许多命令,最好的方法是创建一个bash文件。例如 commands.sh 这样的

In case you want to run many commands at entrypoint, the best idea is to create an bash file. For example commands.sh like this

#!/bin/bash
mkdir /root/.ssh
echo "Something"
cd tmp
ls
...

然后,在您的DockerFile中,将入口点设置为 commands.sh 文件(该文件将执行并运行您的所有Mand内部)

And then, in your DockerFile, set entrypoint to commands.sh file (that execute and run all your mands inside)

COPY commands.sh /scripts/commands.sh
RUN ["chmod", "+x", "/scripts/commands.sh"]
ENTRYPOINT ["/scripts/commands.sh"]

之后,每次启动容器时。 commands.sh 将被执行并运行您需要的所有命令。您可以在此处查看 https://github.com/dangminhtruong/drone-chatwork

After that, each time you start your container. commands.sh will be execute and run all commands that you need. You can take a look here https://github.com/dangminhtruong/drone-chatwork

这篇关于docker ENTRYPOINT上的多个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆