Reputation: 514
Short question. I have the following Dockerfile:
FROM node:6.9.2
RUN apt-get update
RUN useradd --user-group --create-home --shell /bin/false app
ENV HOME=/home/app
RUN mkdir -p $HOME
RUN chown -R app:app $HOME
USER app
WORKDIR $HOME/
VOLUME ["/home/app/uploads"]
EXPOSE 5001
CMD [ "npm", "run", "test-integration" ]
and the corresponding docker-compose: version: '2.0'
services:
komed-test-integration:
image: borntraegermarc/komed-test-integration
container_name: komed-test-integration
build: .
depends_on:
- komed-app
- komed-mongo
volumes:
- .:/home/app
environment:
- HOST_URL=komed-app
- HOST_PORT=5001
- MONGO_HOST=komed-mongo
- MONGO_DATABASE=komed-health
I have the dependency to komed-app
in my compose file and that works fine. But how do I wait for these integration tests to start until the web server (komed-app
) is actually running? Tried with CMD [ "./wait-for-it.sh", "komed-app-test:5001", "--", "npm", "run", "test-integration" ]
but didn't work. Always get the error exited with code 127
.
Any ideas?
Upvotes: 1
Views: 2413
Reputation: 1326994
The best practice is described in Controlling startup order in Compose.
You can either use depends-on
or (better) vishnubob/wait-for-it
(which you did).
127 is mentioned in this issue, when the timeout fails.
Docker node 6.9.2 depends on jessie, not Alpine, so it should not be affected by issue 6: so try and debug the script, by adding -x to the first line
#!/usr/bin/env bash -x
You will see which exit $RESULT
produced that 127 error code.
The OP Marc Borni confirms in the comments the origin of the issue: windows file encoding for a unix script.
Sometimes, using dos2unix
directly in a Dockerfile
can help.
Upvotes: 1