3

How to run docker-compose entrypoint configuration option with multiple or multiline bash commands

commands:

yarn install
yarn build
sleep infinity

1 Answer 1

4

I figured out how!

Steps:

  1. In docker-compose.yml, say for service: gvhservice, add below lines of code
  gvhservice:
    entrypoint:
      - "/bin/sh"
      - -ecx
      - |
          yarn install
          yarn build
          sleep infinity
  1. optionally, add all these commands to a file say - entrypoint.sh

Where in entrypoint.sh, add below lines of code:

#!/bin/sh

set -ex

yarn install
yarn build
sleep infinity

where in docker-compose.yml, add below lines of code:

  gvhservice:
    entrypoint: entrypoint.sh
  1. By using combination of a docker ENTRYPOINT instruction within the container and command instruction and operator | configuration option in docker-compose.yml (suitable for a variable number of commands to be passed during runtime)

build you container with instruction: COPY entrypoint.sh . and

where contents of entrypoint.sh is:

#!/bin/sh

set -ex

exec "$@"

where in docker-compose.yml, add below lines of code

  gvhservice:
    entrypoint: entrypoint.sh
    command:
      - "/bin/sh"
      - -ecx
      - |
          yarn install
          yarn build
          sleep infinity
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.