https://github.com/amulyakashyap09/wait_for_service_not_container
A tutorial on how to wait for services within docker containers.
https://github.com/amulyakashyap09/wait_for_service_not_container
bash-script bash-scripting docker docker-compose docker-compose-files docker-compose-wait dockerfiles elasticsearch kafka kibana mongodb rabbitmq shell shell-scripting shell-scripts shellscript wait-for-it
Last synced: 4 months ago
JSON representation
A tutorial on how to wait for services within docker containers.
- Host: GitHub
- URL: https://github.com/amulyakashyap09/wait_for_service_not_container
- Owner: amulyakashyap09
- License: mit
- Created: 2018-07-12T11:29:56.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-14T07:49:35.000Z (about 8 years ago)
- Last Synced: 2025-01-07T09:47:08.114Z (over 1 year ago)
- Topics: bash-script, bash-scripting, docker, docker-compose, docker-compose-files, docker-compose-wait, dockerfiles, elasticsearch, kafka, kibana, mongodb, rabbitmq, shell, shell-scripting, shell-scripts, shellscript, wait-for-it
- Language: Shell
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Docker Compose Wait For Services Script
> A tutorial on how to wait for services within docker containers.
## Explanation
> Instead of putting your `wait-script` in `docker-compose.yaml` (as shown in docker-compose docs).
> You should put your `wait-script` within your source(src) folder
> And execute `wait.sh` from Dockerfile.
> Whenever your `docker-compose.yaml` file executes it builds from `Dockerfile` and your script executes.
> Now, execute your binary (`golang binary`) / main file `(main.js)` from `wait.sh`
## Contributing [](https://github.com/dwyl/esta/issues)  
* All pull requests are **welcomed**
* Mail me at `amulyakashyap09@gmail.com`
## Usage
1. Add your services in your **docker-compose.yaml** file (`vi docker-compose.yaml`)
```
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
build: .
ports:
- "9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: 192.168.99.100
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock
```
2. Now, Kafka will be accessible via [http://localhost:9092](http://localhost:9092)
3. Add this command `localhost:9200` to **wait.sh** file (`vi wait.sh`)
```
declare -a HOSTS=("localhost:27017" "localhost:9200" "localhost:5601" "localhost:15672", "localhost:9092")
```
4. Run Command `docker-compose up`