All Projects → ufoscout → Docker Compose Wait

ufoscout / Docker Compose Wait

Licence: apache-2.0
A simple script to wait for other docker images to be started while using docker-compose

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Docker Compose Wait

Bitnami Docker Suitecrm
SuiteCRM container image
Stars: ✭ 105 (-88.89%)
Mutual labels:  containers, docker-images
Analyze Local Images
deprecated tool for interacting with Clair locally
Stars: ✭ 12 (-98.73%)
Mutual labels:  containers
Cdk Gitlab Runner
Create Gitlab Runner via AWS CDK.
Stars: ✭ 23 (-97.57%)
Mutual labels:  containers
Docker Gitlab
Dockerized GitLab
Stars: ✭ 7,084 (+649.63%)
Mutual labels:  containers
Csp
The Cyber Security Platform MeliCERTes is part of the European Strategy for Cyber Security. MeliCERTes is a network for establishing confidence and trust among the national Computer Security Incident Response Teams (CSIRTs) of the Member States and for promoting swift and effective operational cooperation.
Stars: ✭ 23 (-97.57%)
Mutual labels:  containers
Linuxkit
A toolkit for building secure, portable and lean operating systems for containers
Stars: ✭ 7,166 (+658.31%)
Mutual labels:  containers
Bane
Custom & better AppArmor profile generator for Docker containers.
Stars: ✭ 902 (-4.55%)
Mutual labels:  containers
Foundationsync
Synchronize User Profiles with Active Directory in SharePoint Foundation
Stars: ✭ 21 (-97.78%)
Mutual labels:  synchronization
Brmgr
Manage bridge devices and provide DHCP and DNS services to connected interfaces.
Stars: ✭ 11 (-98.84%)
Mutual labels:  containers
Ansible Role Docker
Ansible Role - Docker
Stars: ✭ 845 (-10.58%)
Mutual labels:  containers
Subuser
Run programs on linux with selectively restricted permissions.
Stars: ✭ 842 (-10.9%)
Mutual labels:  containers
Kitura On Kubernetes
Develop a Full-Stack Swift application with a native iOS app and Kitura on Kubernetes
Stars: ✭ 24 (-97.46%)
Mutual labels:  containers
Sdn Handbook
SDN网络指南(SDN Handbook)
Stars: ✭ 856 (-9.42%)
Mutual labels:  containers
Dockerfiles Windows
Various Dockerfiles for Windows Containers
Stars: ✭ 920 (-2.65%)
Mutual labels:  docker-images
Felix
Project Calico's per-host agent Felix, responsible for programming routes and security policy.
Stars: ✭ 871 (-7.83%)
Mutual labels:  containers
Pavlos
A light-weight container runtime for Linux with NVIDIA gpu support, allows developers to quicky setup development environments for dev and test. Pavlos can emulate any Linux rootfs image as a container.
Stars: ✭ 22 (-97.67%)
Mutual labels:  containers
Containers From Scratch
Writing a container in a few lines of Go code, as seen at DockerCon 2017 and on O'Reilly Safari
Stars: ✭ 839 (-11.22%)
Mutual labels:  containers
Trivy
Scanner for vulnerabilities in container images, file systems, and Git repositories, as well as for configuration issues
Stars: ✭ 9,673 (+923.6%)
Mutual labels:  containers
Opencast Docker
Dockerfiles for Opencast
Stars: ✭ 27 (-97.14%)
Mutual labels:  docker-images
Caprover
Scalable PaaS (automated Docker+nginx) - aka Heroku on Steroids
Stars: ✭ 7,964 (+742.75%)
Mutual labels:  containers

docker-compose-wait

Build Status codecov Codacy Badge FOSSA Status

A small command line utility to wait for other docker images to be started while using docker-compose. It permits to wait for a fixed amount of seconds and/or to wait until a TCP port is open on a target image.

Usage

This utility should be used in the docker build process and launched before your application starts.

For example, your application "MySuperApp" uses MongoDB, Postgres and MySql (wow!) and you want to be sure that, when it starts, all other systems are available, then simply customize your dockerfile this way:

## Use whatever base image
FROM alpine

## Add your application to the docker image
ADD MySuperApp.sh /MySuperApp.sh

## Add the wait script to the image
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.8.0/wait /wait
RUN chmod +x /wait

## Launch the wait tool and then your application
CMD /wait && /MySuperApp.sh

Done! the image is ready.

Now let's modify the docker-compose.yml file:

version: "3"

services:
  mongo:
    image: mongo:3.4
    hostname: mongo
    ports:
      - "27017:27017"

  postgres:
    image: "postgres:9.4"
    hostname: postgres
    ports:
      - "5432:5432"

  mysql:
    image: "mysql:5.7"
    hostname: mysql
    ports:
      - "3306:3306"

  mySuperApp:
    image: "mySuperApp:latest"
    hostname: mySuperApp
    environment:
      WAIT_HOSTS: postgres:5432, mysql:3306, mongo:27017

When docker-compose is started (or Kubernetes or docker stack or whatever), your application will be started only when all the pairs host:port in the WAIT_HOSTS variable are available. The WAIT_HOSTS environment variable is not mandatory, if not declared, the script executes without waiting.

If you want to use the script directly in docker-compose.yml instead of the Dockerfile, please note that the command: configuration option is limited to a single command so you should wrap in a sh call. For example:

command: sh -c "/wait && /MySuperApp.sh"

This is discussed further here and here.

Do note the recommended way of using wait is with the shell operator &&, which implies the requirement of a shell. This introduces a requirement for Docker use where bases images like scratch not offering a shell cannot be used.

Instead the recommendation for base Docker images are ones offering a shell like alpine, debian etc. and if you want to aim for minimalism, evaluate something like: busybox

Additional configuration options

The behaviour of the wait utility can be configured with the following environment variables:

  • WAIT_LOGGER_LEVEL : the output logger level. Valid values are: debug, info, error, off. the default is debug.
  • WAIT_HOSTS: comma separated list of pairs host:port for which you want to wait.
  • WAIT_HOSTS_TIMEOUT: max number of seconds to wait for all the hosts to be available before failure. The default is 30 seconds.
  • WAIT_HOST_CONNECT_TIMEOUT: The timeout of a single TCP connection to a remote host before attempting a new connection. The default is 5 seconds.
  • WAIT_BEFORE_HOSTS: number of seconds to wait (sleep) before start checking for the hosts availability
  • WAIT_AFTER_HOSTS: number of seconds to wait (sleep) once all the hosts are available
  • WAIT_SLEEP_INTERVAL: number of seconds to sleep between retries. The default is 1 second.

Using on non-linux systems

The simplest way of getting the wait executable is to download it from

https://github.com/ufoscout/docker-compose-wait/releases/download/{{VERSION}}/wait

This is a pre-built executable for Linux x64 systems which are the default ones in Docker. In addition, it is built with MUSL for maximum portability.

If you need it for a different architecture, you should clone this repository and build it for your target.

As it has no external dependencies, an being written in the mighty rust programming language, the build process is just a simple cargo build --release (well... of course you need to install the rust compiler before...)

For everything involving cross-compilation, you should take a look at Cross.

For example, to build for a raspberry pi, everything you have to do is:

  1. Install the latest stable rust toolchain using rustup
  2. Correctly configure Docker on your machine
  3. Open a terminal and type:
cargo install cross
cross build --target=armv7-unknown-linux-musleabihf --release

Use your shiny new executable on your raspberry device!

Notes

This utility was explicitly written to be used with docker-compose; however, it can be used everywhere since it has no dependencies on docker.

License

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].