Skip to content
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

Doesn't work inside docker-compose.yml #8

Closed
iraycd opened this issue Jan 19, 2019 · 6 comments
Closed

Doesn't work inside docker-compose.yml #8

iraycd opened this issue Jan 19, 2019 · 6 comments

Comments

@iraycd
Copy link

iraycd commented Jan 19, 2019

  app:
    container_name: app
    tty: true
    build: .
    command: "/wait && yarn test"
app | Host db:8529 is now available
app exited with code 0
@ufoscout
Copy link
Owner

@iraycd
What is the issue exactly? The line "Host db:8529 is now available" is printed by the docker-compose-wait tool, so it is working as expected from what I see.
When all the hosts are available, the tool ends merely its execution and the part after the "&&" is executed.
Consequently, the fact that your app exited with code 0, could depend on the "yarn test" part of your command.
Please, provide more information and context.

@iraycd
Copy link
Author

iraycd commented Jan 19, 2019

@ufoscout I have tested it with few other commands it doesn’t seem to work.

It works when I right in Dockerfile, but not in docker-compose.yml

Works: Dockerfile

CMD /wait && yarn test 

Doesn't work: docker-compose.yml

 command: "/wait && yarn start"

@ufoscout
Copy link
Owner

@iraycd
the docker-compose documentation uses a different syntax than yours for the command:

command: bundle exec thin -p 3000

or:

command: ["bundle", "exec", "thin", "-p", "3000"]

Could you please try one these two?

@iraycd
Copy link
Author

iraycd commented Jan 19, 2019

Didn't work

@iraycd
the docker-compose documentation uses a different syntax than yours for the command:

command: bundle exec thin -p 3000

or:

command: ["bundle", "exec", "thin", "-p", "3000"]

Could you please try one these two?

@ufoscout
Copy link
Owner

@iraycd
I got it. It has nothing to do with the wait tool, it seems that docker-compose default behaviour is to execute only the first command.
See here and here for a workaround.

For what I see, it should work this way:

command: sh -c "/wait && yarn test"

or

command: bash -c "/wait && yarn test"

@iraycd
Copy link
Author

iraycd commented Jan 19, 2019

@iraycd
I got it. It has nothing to do with the wait tool, it seems that docker-compose default behaviour is to execute only the first command.
See here and here for a workaround.

For what I see, it should work this way:

command: sh -c "/wait && yarn test"

or

command: bash -c "/wait && yarn test"

Wow, I missed that point, thank you. 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants