[英]docker-compose run multiple commands for a service
I am using docker on windows - version 18.03
(client)/ 18.05
(server).我在 Windows 上使用 docker - 版本18.03
(客户端) 18.05
(服务器)。 I have created docker-compose
file for ELK stack.我已经为 ELK 堆栈创建了docker-compose
文件。 Everything is working fine.一切正常。 What I would like to do is, to install logtrail
before kibana is started.我想做的是,在启动logtrail
。 I was thinking about copying logtrail*.zip
first, then call install:我正在考虑先复制logtrail*.zip
,然后调用安装:
container_name: kibana
(...)
command:
- docker cp kibana:/ ./kibana/logtrail/logtrail-6.7.1-0.1.31.zip
- /bin/bash
- ./bin/kibana-plugin install/logtrail-6.7.1-0.1.31.zip
But that doesn't look like right way as first of all it doesn't work, second of all I am not sure if I can call mutliple commands like I did and third of all I'm not sure if docker cp
in command
is even allowed on that stage of service creation但这看起来并不正确,因为首先它不起作用,其次我不确定我是否可以像我那样调用多个命令,第三我不确定command
中的docker cp
是否是甚至允许在服务创建的那个阶段
command:
- /bin/bash
- -c
- |
echo "This is a multiline command"
echo "See how I escape $$ sign"
echo $$PATH
You can run multiple commands like above however you can not run docker cp
as in your command.您可以像上面那样运行多个命令,但是您不能像在命令中那样运行docker cp
。
You can run multiple commands for a service in docker compose by:您可以通过以下方式在 docker compose 中为服务运行多个命令:
command: sh -c "command1 && command2 && command2"
THATS MY SOLUTION FOR THIS CASE:这就是我对这种情况的解决方案:
# OPTION 01:
# command: >
# bash -c "chmod +x /scripts/rs-init.sh
# && sh /scripts/rs-init.sh"
# OPTION 02:
# entrypoint: [ "bash", "-c", "chmod +x /scripts/rs-init.sh && sh /scripts/rs-init.sh"]
If you're looking to install software David Maze's comment seems to be the standard path.如果您要安装软件,David Maze 的评论似乎是标准路径。 If you want to actually run multiple commands look at the answer to this SO question Using Docker-Compose, how to execute multiple commands如果您想实际运行多个命令,请查看此 SO 问题的答案Using Docker-Compose, how to execute multiple commands
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.