Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose run multiple commands for a service

Tags:

docker

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

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

like image 716
user3529850 Avatar asked Apr 19 '19 20:04

user3529850


People also ask

Can docker container run multiple services?

It's ok to have multiple processes, but to get the most benefit out of Docker, avoid one container being responsible for multiple aspects of your overall application. You can connect multiple containers using user-defined networks and shared volumes.

Can we have 2 CMD in docker file?

There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect. If CMD is used to provide default arguments for the ENTRYPOINT instruction, both the CMD and ENTRYPOINT instructions should be specified with the JSON array format.

Can we run more than one application in docker compose?

The docker-compose. yml file allows you to configure and document all your application's service dependencies (other services, cache, databases, queues, etc.). Using the docker-compose CLI command, you can create and start one or more containers for each dependency with a single command (docker-compose up).


1 Answers

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.

like image 173
Root G Avatar answered Oct 12 '22 13:10

Root G