• [Docker] Ensure Containers Run with High-Availability


    A properly scaled Docker architecture should be able to kill off random containers at any time, and continue to run by implementing a crash-only design methodology. We will learn how to setup our architecture to auto-spawn new Docker containers when other containers are deemed unhealthy or in a terminated state. We will also learn how to scale containers easily with Compose in the event we need to quickly scale horizontally.

    For example we have a nodejs image called helloworld:

    Dockerfile:

    FROM mhart/alpine-node
    COPY index.js .
    CMD node index.js

    To ensure high availablity, we can pass --restart:

    docker run --restart always --name test helloworld

    Another way is using docker-compose.hml:

    version: '3'
    services:
      helloworld:
        image: helloworld
        restart: always

     Run:

    docker-compose up --scale helloworld=3  ## 3 instants

    index.js

    console.log('hello world');
    
    setTimeout(() => process.exit(), 3000);
  • 相关阅读:
    动态规划_leetcode416
    动态规划_leetcode377
    基础整理
    super使用简介
    PHP替换指定字符串
    yii安装redis扩展(Windows)
    PHP多维数组去重
    git pull
    vue页面部署并移除url里面的#号
    fatal: refusing to merge unrelated histories(git pull)
  • 原文地址:https://www.cnblogs.com/Answer1215/p/14365046.html
Copyright © 2020-2023  润新知