New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running multiple commands in entrypoint #52

Closed
imaia opened this Issue Dec 27, 2016 · 4 comments

Comments

Projects
None yet
4 participants
@imaia

imaia commented Dec 27, 2016

I'm trying to copy some files before running my entrypoint script. I tried something like this in my docker-compose.yml:

entrypoint: ["sh", "-c", "cp -r /usr/src/redmine/public/. /www/public/ && /docker-entrypoint.sh"]

But I'm getting a exit code 0. Suggestions?

@abcfy2

This comment has been minimized.

abcfy2 commented Dec 28, 2016

You don't need to modify entrypoint, just set command.

    command:
      - /bin/sh
      - -c
      - |
          bundle config mirror.https://rubygems.org https://gems.ruby-china.org
          bundle exec rake redmine:plugins:migrate RAILS_ENV=production
          bundle exec rake tmp:cache:clear tmp:sessions:clear RAILS_ENV=production
          /docker-entrypoint.sh passenger start

YAML supports multiline string.

@jadekler

This comment has been minimized.

jadekler commented Aug 18, 2017

Awesome solution @abcfy2

imacks added a commit to dockerguys/ranchcat that referenced this issue Apr 5, 2018

docker-registry image
proper way to implement multiline commands with docker-compose, tks to docker-library/redmine#52
@tianon

This comment has been minimized.

Member

tianon commented Apr 24, 2018

Closing, given the excellent solution posted above. 👍

(The only change I'd personally make is adding exec before the invocation of /docker-entrypoint.sh to ensure the outer shell process gets ditched and Redmine properly becomes PID 1.)

@tianon tianon closed this Apr 24, 2018

@abcfy2

This comment has been minimized.

abcfy2 commented Apr 25, 2018

No problem. Because the last line of /docker-entrypoint.sh is exec "$@", so this script will ensure Redmine become PID 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment