docker-compose为服务运行多个命令 [英] docker-compose run multiple commands for a service

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

问题描述

我在Windows上使用docker-版本 18.03 (客户端)/ 18.05 (服务器).我已经为ELK堆栈创建了 docker-compose 文件.一切正常.我想做的是,在启动kibana之前安装 logtrail .我当时正在考虑先复制 logtrail * .zip ,然后再调用install:

I am using docker on windows - version 18.03 (client)/18.05 (server). I have created docker-compose file for ELK stack. Everything is working fine. What I would like to do is, to install logtrail before kibana is started. I was thinking about copying logtrail*.zip first, then call install:

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

但是这看起来不正确,因为首先它不起作用,其次我不确定是否可以像我一样调用多行命令,并且我不确定是否 command 中使用> docker cp

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:
- /bin/bash
- -c
- |
  echo "This is a multiline command"
  echo "See how I escape $$ sign"
  echo $$PATH

您可以像上面那样运行多个命令,但是不能像命令中那样运行 docker cp .

You can run multiple commands like above however you can not run docker cp as in your command.

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

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