I will write about Dockerize
which is convenient when you want to wait for DB connection when using docker-compose
.
As far as I can see below, it seems that wait-for-it
and dockerize
are valid.
Controlling the startup order in Compose — Docker-docs-ja 17.06 Document
Wait until MySQL starts with Docker Compose-Qiita How to wait until MySQL starts with docker-compose up (2 types introduced) --Qiita
Dockerize
GitHub - jwilder/dockerize: Utility to simplify running applications in docker containers
Modify dockerfile
and docker-compose.yaml
.
ENV DOCKERIZE_VERSION v0.6.0
RUN apk add --no-cache openssl \
&& wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
Define the dockerize
command with docker-compose
.
The command dockerize -wait tcp: // db: 5432
will allow you to wait for the dependent application to start.
entrypoint:
- dockerize
- -timeout
- 60s
- -wait
- tcp://mysql:3306
command: ./main #Run with go
Wait for other containers to start using Dockerize-Qiita
Recommended Posts