Doesn't work inside docker-compose.yml
iraycd opened this issue · 6 comments
app:
container_name: app
tty: true
build: .
command: "/wait && yarn test"
app | Host db:8529 is now available
app exited with code 0
@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.
@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"
@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?
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?
@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. 💯