re: Getting started with Docker Compose VIEW POST


For MySQL health check I use:

  test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] # this is not precise, use as last resort
  timeout: 20s
  retries: 15

And it works in most cases, its true that I might have been just lucky for hundreds of docker-compose ups.

Note: I stole it from somewhere, and I do not remember the original author.

One more tip that this post is missing are logs; so for NGINX you would also need a Dockerfile with

FROM nginx

RUN  echo "daemon off;" >> /etc/nginx/nginx.conf

COPY default /etc/nginx/conf.d/default.conf

# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
    && ln -sf /dev/stderr /var/log/nginx/error.log

CMD ["nginx"]

Now you can do docker logs -f <container> and logs from NGINX are there :)

Note: I stole this from (Chris Fidao)

code of conduct - report abuse