wait-for-it | Wait for service to be | TCP library
kandi X-RAY | wait-for-it Summary
kandi X-RAY | wait-for-it Summary
Wait for service(s) to be available before executing a command. wait-for-it is a script that will wait on the availability of one or more TCP services (i.e. host:port) before executing a user-defined command. It is useful for synchronizing the spin-up of interdependent services, such as linked docker containers. Since v2.0.0, wait-for-it will return the exit code of the executed command(s).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Handles the command line interface
- Implements the command line interface
- Context manager to exit on_exit
- Waits until a connection is available
- Determine host and port
- Called when the timeout is received
- Callback called when the job is finished
- Connect to a service
- Called when a timeout occurs
- Wait until the connection is available
- Handles message
- Connects all serial services
- Send a failure message
- Connect to all parallel services
- Send the neutral message
- Tell the success message
wait-for-it Key Features
wait-for-it Examples and Code Snippets
$ wait-for-it \
--service www.google.com:80 \
-- echo "google is up"
[*] Waiting 15 seconds for www.google.com:80
[+] www.google.com:80 is available after 0 seconds
google is up
$ wait-for-it \
--service www.google.com:80 \
--timeout 0 \
-- echo "g
Usage: wait-for-it [OPTIONS] [COMMANDS]...
Wait for service(s) to be available before executing a command.
Options:
-h, --help Show this message and exit.
-v, --version Show the version and exit.
-q, --quiet
Community Discussions
Trending Discussions on wait-for-it
QUESTION
I deployed a go with gorm app using postgres by docker-compose.
I did db creation and data migration by an another container service. Here only listed the app and db container issues.
docker-compose.yml
...ANSWER
Answered 2021-Jun-02 at 06:57you need to add the Time for waiting in your command:
QUESTION
I am dockerizing an application with two services in docker-compose.yml: a web image build from php:7.3.28-apache and a database image build from postgres:11.12-alpine. Inside database Dockerfile I am executing a sql file to populate the database by doing:
COPY ./dump.sql /docker-entrypoint-initdb.d/
In my web image I do a migration. But the migration should only occur after the database end executing the sql file. So I use the wait-for-it.sh script to wait for the database port to be available:
...ANSWER
Answered 2021-May-27 at 14:02Solution is to utilise HEALTHCHECK [OPTIONS] CMD command
The command after the CMD keyword can be either a shell command (e.g. HEALTHCHECK CMD /bin/check-running
) or an exec array (as with other Dockerfile commands; see e.g. ENTRYPOINT for details).
The command’s exit status indicates the health status of the container. The possible values are:
0: success - the container is healthy and ready for use
1: unhealthy - the container is not working correctly
2: reserved - do not use this exit code
Probably you can create some shell script
QUESTION
this is my first project with Django and also my first time using Docker. So far I'm really enjoying both of them but I'm facing a problem I couldn't resolve after a week.
I followed this tutorial to build my project : https://medium.com/swlh/setting-up-a-secure-django-project-repository-with-docker-and-django-environ-4af72ce037f0
So far, my project structure looks like like this :
...ANSWER
Answered 2021-May-22 at 14:39Answering my own question as I have FINALLY found the cause of all my troubles ...
I had created an __init__.py
file at the root of my project to define a project version as a constant..
After reading here and there about Django modules and namespaces, I removed the __init__.py
from my root directory and that solved the problem.
**edited my question above to show the file in question
QUESTION
I'm working on using Django and Docker with MariaDB on Mac OS X.
I'm trying to grant privileges to Django to set up a test db. For this, I have a script that executes this code, sudo docker exec -it $container mysql -u root -p
. When I do this after spinning up, instead of the prompt for the password for the database, I get this error message,
OCI runtime exec failed: exec failed: container_linux.go:370: starting container process caused: exec: "mysql": executable file not found in $PATH: unknown
On an Ubuntu machine, I can delete the data folder for the database and spin up, spin down, and run the command without the error, but on my Mac, which is my primary machine that I'd like to use, this fix doesn't work. Any ideas? I've had a peer pull code and try it on their Mac and it does the same thing to them! Docker is magic to me.
Here's my docker-compose.yml.
...ANSWER
Answered 2021-Apr-30 at 02:53I fixed it!
This is really silly, but OS X doesn't like the "$container" so if you explicitly just write the name of container for the database, it works like a charm!
QUESTION
I am working in a Java spring boot application, running as a docker container.
The main purose of this application was to execute python scripts. So inside the docker container, I had to make available python environment. I added the python runtime with this code. But seems this is very basic python verson and I can not make other important libraries available.
Like, I wanted to add 'asyncpg' library so that I can use connection pool.
But it is not letting me to add asyncpg library.
Below is the docker file.
Note: I have commented '#FROM python:3.6-alpine', if I make this open then java runtime will not be available which is 'FROM openjdk:8u191-jre-alpine3.8'
------- Docker file --------------
...ANSWER
Answered 2021-Apr-20 at 10:56I have got one solution .. that at the first line of the docker file, I will first decleare the 'FROM alpine:3.7', and then inside the docker file I will keep adding the required runtimes and the dependent libraries accordingly. This way we can add mutiple runtimes.
Below the working docker compose where I have commented out both the lines for openjdk and python runtime and added FROM alpine:3.7: Also some trick to add asyncpg library to the python runtime. This way I can now add any dependencies. I can now work on asyncpg.
-------- Docker file ----------------
QUESTION
I didn't understand anything what is the best way to deploy my docker service to production?
My compose file:
...ANSWER
Answered 2021-Apr-10 at 18:09The compose file you have isn't an image itself; its a means to manage a collection of images. This mean you wouldn't upload the docker-compose file itself to dockerhub, but rather the images for each service. 'Deploying' a docker-compose file is (generally) a matter of copying the docker-compose file to your server and running docker-compose up -d
(or making a service that automates this, perhaps with systemd). Any image in the compose file will be pulled automatically.
For your specific compose file, you are defining the images locally for the nginx
service and the app
service, in which case you have two options:
- Copy
./nginx
and/or./app
to your server and run the compose file as-is. This will build the image locally when you calldocker-compose
and skip uploading it to dockerhub - run
docker build ./app -t yourtag
(and same for./nginx
if desired) and push to dockerhub withdocker push yourimage:yourtag
. In that case you would need to edit the compose file to pull the images and tags you defined when building them.
QUESTION
I am in the process of programming some tests in Python. In one test, I am using a container that loads data from a database when the container starts.
In the test I modify the data in the database and restart the container with os.system("docker-compose restart predict")
, so the latest data is loaded in the container.
Is there (besides the wait-for-it.sh
repo) an option to wait with the execution until the container is up and running, directly in python?
ANSWER
Answered 2021-Mar-17 at 10:41To wait-for-it.sh
is pooling the resources exposed from for the container and waits for the resource to became available (ip address, exposed port, or both).
Following is a canonical approach with python
and docker-py
(docker's own python library) which will help you to orchestrate your containers even better.
First we import the packages that we need and crate a client to the docker engine
QUESTION
I am trying to work on a webscraper using the Serverless Framework that I want to be easily ran locally by users without having to install any necessary depedencies on their local machine. I am using serverless-offline-sqs with a local Elasticmq server hosted on a Docker container.
Currently, I have a docker-compose file that I run, then run serverless offline
in another terminal which works well. That docker-compose.yml
file looks like this:
ANSWER
Answered 2021-Jan-27 at 15:24The problem is likely to be in ECONNREFUSED 0.0.0.0:9324
. Judging by the port number it is an attempt to reach the sqs
service, but the IP-address is bad. It should connect to sqs:9324
or an IP-address of that container. 0.0.0.0
means 'any IP-address' and it is usually used to bind a port. Check your serverless
configuration.
Also, you can easily check if you are in a 'race condition' or not. For that simply start your services one by one using several terminals:
QUESTION
I have cross browser tests that I have written with selenium. Since I want to test multiple browsers on multiple platforms I use docker virtualization and selenium grid. I could execute my tests without docker via localhost:4444 with this docker-compose.yml
ANSWER
Answered 2021-Jan-13 at 10:12There's a bridge (by default in Docker Compose) between your services, and you can access to another service by :
, so you can access hub service by hub:4444
.
From the official Docker Compose documentation, as you can read here:
You can control the order of service startup and shutdown with the depends_on option. Compose always starts and stops containers in dependency order, where dependencies are determined by depends_on, links, volumes_from, and network_mode: "service:...".
As you did with depends_on, but
Docker Compose official solutionHowever, for startup Compose does not wait until a container is “ready” (whatever that means for your particular application) - only until it’s running. There’s a good reason for this.
Use a tool such as wait-for-it, dockerize, sh-compatible wait-for, or RelayAndContainers template. These are small wrapper scripts which you can include in your application’s image to poll a given host and port until it’s accepting TCP connections.
They suggest you to act like this:
QUESTION
I'm trying to configure a deployed app on an EC2 instance I'm not able to get visit the application when it's up on ec2 public IP. I've checked the security groups and allowed all inbound traffic to ports just to see If I can reach the homepage or admin page of django.
Say my ec2 IP address is 34.245.202.112 how do I map my application so nginx serves
The frontend(nuxt) at 34.245.202.112
The backend(django) at 34.245.202.112/admin
The API(DRF) at 34.245.202.112/api
When I try to do this the error I get from nginx is
nginx | 2020-11-14T14:15:35.511973183Z 2020/11/14 14:15:35 [emerg] 1#1: host not found in upstream "nuxt:3000" in /etc/nginx/conf.d/autobets_nginx.conf:9
This is my config
docker-compose
version: "3.4"
...ANSWER
Answered 2020-Nov-25 at 17:37Look at this minimal example:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install wait-for-it
You can use wait-for-it like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page