1

As other answers have noted, I'm trying to run multiple commands in docker-compose, but my container exits without any errors being logged. I've tried numerous variations of this in my docker-compose file:

command: echo "the_string_for_the_file" > ./datahub-frontend/conf/user.props && datahub-frontend/bin/datahub-frontend

The Dockerfile command is:

CMD ["datahub-frontend/bin/datahub-frontend"]

My Real Goal

Before the application starts, I need to create a file named user.props in a location ./datahub-frontend/conf/ and add some text to that file.

Annoying Constraints

  • I cannot edit the Dockerfile
  • I cannot use a volume + some init file to do my bidding

Why? DataHub is an open source project for documenting data. I'm trying to create a very easy way for non-developers to get an instance of DataHub hosted in the cloud. The hosting we're using (AWS Elastic Beanstalk) is cool in that it will accept a docker-compose file to create a web application, but it cannot take other files (e.g. an init script). Even if it could, I want to make it really simple for folks to spin up the container: just a single docker-compose file.

Reference:

The container image is located here: https://registry.hub.docker.com/layers/datahub-frontend-react/linkedin/datahub-frontend-react/465e2c6/images/sha256-e043edfab9526b6e7c73628fb240ca13b170fabc85ad62d9d29d800400ba9fa5?context=explore

Thanks!

1
  • If by some chance someone in the future finds this and you're trying to deploy datahub, the chosen answer does answer my question, but unfortunately datahub didn't like that approach. It seems the command in the Dockerfile uses an env var, so you need to leave that command there and not add another to docker-compose. The only option I can think of is to use a volume to copy the user.props file into the docker container Commented Aug 1, 2022 at 13:07

1 Answer 1

1

You can use bash -c if your docker image has bash

Something like this should work: command: bash -c "echo \"the_string_for_the_file\" > ./datahub-frontend/conf/user.props && datahub-frontend/bin/datahub-frontend"

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. For other folks in future, if your image doesn't have bash you can use command: sh -c "echo ...

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.