docker-compose-wait work fine but dont start container
sptGabriel opened this issue · 6 comments
Hello I am having difficulty using the docker-compose-wait for my project
I have this docker file:
#building code
FROM node:lts-alpine
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.7.3/wait /wait
RUN chmod +x /wait
RUN mkdir -p /home/node/api && chown -R node:node /home/node/api
WORKDIR /home/node/api
COPY ormconfig.json .env package.json yarn.* ./
USER node
RUN yarn
COPY --chown=node:node . .
EXPOSE 4000
CMD ["/wait", "yarn", "dev" ]
and this docker compose:
version: '3.7'
services:
db-pg:
image: postgres:12
container_name: db-pg
ports:
- '${DB_PORT}:5432'
environment:
ALLOW_EMPTY_PASSWORD: 'no'
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASS}
POSTGRES_DB: ${DB_NAME}
volumes:
- ci-postgres-data:/data
ci-api:
build: .
container_name: ci-api
volumes:
- .:/home/node/api
ports:
- '${SERVER_PORT}:${SERVER_PORT}'
depends_on:
- db-pg
environment:
WAIT_HOSTS: db-pg:5432
logging:
driver: 'json-file'
options:
max-size: '10m'
max-file: '5'
volumes:
ci-postgres-data:
i got this:
ci-api | --------------------------------------------------------
ci-api | docker-compose-wait 2.7.3
ci-api | ---------------------------
ci-api | Starting with configuration:
ci-api | - Hosts to be waiting for: [db-pg:5432]
ci-api | - Timeout before failure: 30 seconds
ci-api | - TCP connection timeout before retry: 5 seconds
ci-api | - Sleeping time before checking for hosts availability: 0 seconds
ci-api | - Sleeping time once all hosts are available: 0 seconds
ci-api | - Sleeping time between retries: 1 seconds
ci-api | --------------------------------------------------------
ci-api | Checking availability of db-pg:5432
ci-api | Host db-pg:5432 is now available!
ci-api | --------------------------------------------------------
ci-api | docker-compose-wait - Everything's fine, the application can now start!
but my project in node js is not starting
Hi @sptGabriel
As I read the CMD
part of the Dockerfile
you are providing arguments to wait
. This will not work with the current implementation.
You should write something along the lines of:
CMD /wait && yarn dev
Do note the above is untested.
Please see the example in the documentation using: CMD
, which demonstrates the shell form and see the Docker documentation.
CMD / wait && yarn dev
i use
CMD / wait && yarn dev
and get : ci-api | /bin/sh: /: Permission denied
if use:
CMD ["/wait", "yarn", "dev" ]
ci-api | --------------------------------------------------------
ci-api | Checking availability of db-pg:5432
ci-api | Host db-pg:5432 is now available!
ci-api | --------------------------------------------------------
ci-api | docker-compose-wait - Everything's fine, the application can now start!
ci-api | --------------------------------------------------------
docker-compose-wait work but dont start my node
Hi @sptGabriel
I need to come up with an example to replicate your situation. I wonder why you get a permission denied.
i use
CMD / wait && yarn dev
and get : ci-api | /bin/sh: /: Permission denied
Hi @sptGabriel,
you put a white space between "/" and "wait" so the engine is trying to execute the "/" as if it is a command. You shoud use instead: CMD /wait && yarn dev
@ufoscout thank u