zoukankan      html  css  js  c++  java
  • [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);
  • 相关阅读:
    Desert King
    Dropping tests
    01分数规划小结
    简单的数学题
    [HAOI2016]放棋子
    [SDOI2017]数字表格
    诸侯放置
    LJJ爱数数
    车的放置
    [SDOI2014]数表
  • 原文地址:https://www.cnblogs.com/Answer1215/p/14365046.html
Copyright © 2011-2022 走看看