Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Resources for "How to Control Service Startup Order in Docker Compose" presentation @ iQuest K&M, Brașov, 2018.

License

Notifications You must be signed in to change notification settings

satrapu/iquest-keyboards-and-mice-brasov-2018

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iQuest Keyboards & Mice - Brașov - 2018

Table of Contents

This repo contains the resources used during "How to Control Service Startup Order in Docker Compose" presentation at the Keyboards & Mice iQuest public event, which took place in Brașov on June 6th, 2018.

This presentation is based on this article, but while the latter shows a Java console application fetching data from a MySQL database, the former uses a .NET Core console application fetching data from a PostgreSQL database.

SlideShare: https://www.slideshare.net/satrapu/how-to-control-service-startup-order-in-docker-compose

  • Clone this repo
git clone https://github.com/satrapu/iquest-keyboards-and-mice-brasov-2018.git
cd ./iquest-keyboards-and-mice-brasov-2018
  • Start services

    • Using depends_on, condition and service_healthy:
    # Windows - PowerShell console run as admin
    cd .\compose\service-healthy `
    ;cmd /c mklink /J .\sources .\..\..\sources `
    ;docker-compose down --rmi local `
    ;docker-compose build `
    ;docker-compose up app
    # Linux - Bash
    cd ./compose/service-healthy \
    && mkdir ./sources && cp ../../sources/* sources \
    && docker-compose down --rmi local \
    && docker-compose build \
    && docker-compose up app
    • Using Docker Engine API
    # Windows - PowerShell console run as admin
    cd .\compose\docker-engine-api `
    ;cmd /c mklink /J .\sources .\..\..\sources `
    ;$Env:COMPOSE_CONVERT_WINDOWS_PATHS=1 `
    ;docker-compose down --rmi local `
    ;docker-compose build `
    ;docker-compose up app
    # Linux - Bash
    cd ./compose/docker-engine-api \
    && mkdir ./sources && cp ../../sources/* sources \
    && docker-compose down --rmi local \
    && docker-compose build \
    && docker-compose up app
    • Using port checking++
    # Windows - PowerShell console run as admin
    cd .\compose\port-checking++ `
    ;cmd /c mklink /J .\sources .\..\..\sources `
    ;docker-compose down --rmi local `
    ;docker-compose build `
    ;docker-compose up --exit-code-from check_db_connectivity check_db_connectivity `
    ;if ($LASTEXITCODE -eq 0) { docker-compose up app } `
    else { echo "ERROR: Failed to start service due to one of its dependencies!" }
    # Linux - Bash
    cd ./compose/port-checking++ \
    && mkdir ./sources && cp ../../sources/* sources \
    && docker-compose down --rmi local \
    && docker-compose build \
    && docker-compose up --exit-code-from check_db_connectivity check_db_connectivity \
    && if [ $? -eq 0 ]; then docker-compose up app; else echo 'ERROR: Failed to start service due to one of its dependencies!'; fi