zoukankan      html  css  js  c++  java
  • Docker Machine, Compose, and Swarm: How They Work Together

    The three tools are now neatly packaged into what’s called the Docker Toolbox.

    Docker Machine
    1/ create Linux VM
    docker-machine create --driver virtualbox containerhost
    or
    docker-machine create -d virtualbox local
    2/ open docker vm's interface
    eval "$(docker-machine env local)"
    or
    boot2docker shellinit

    3/ stop vm
    docker-machine stop containerhost
    4/ remove vm
    docker-machine rm containerhost

    Docker Compose
    1/ compose docker-compose.yml in repository directory
    2/ docker-compose up

    Docker Swarm
    1/ generate “discovery token”(in vm)
    docker run swarm create
    # The discovery token is actually created using Docker’s public discovery service.

    2/ create Swarm Master(in host machine)
    docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery token://YOURTOKENHERE swarm-master

    3/ create Swarm nodes(in host machine)
    docker-machine create -d virtualbox --swarm --swarm-discovery token://YOURTOKENHERE swarm-agent-00
    docker-machine create -d virtualbox --swarm --swarm-discovery token://YOURTOKENHERE swarm-agent-01

    4/ shut down and remove 'local'

    5/ open Swarm Master shell
    eval $(docker-machine env --swarm swarm-master)
    # Now we have a Swarm Master and two Swarm Nodes running locally,use 'docker info' to check

    6/ run containers on cluster node
    docker run -d redis
    # 0d7af2492be35cc9c7593f6d677185c6c44f3a06898258585c7d2d2f9aa03c2e
    docker run -d nginx
    # 0babf055abf9b487b6bafd4651386075f8d6f46ce9f192849bc32345997438ea

    7/ list the containers scheduled on different clustered
    docker ps

  • 相关阅读:
    linux环境下的时间编程
    golang1.13中重要的新特新
    vs2019+cmake实现Linux远程开发
    现代c++与模板元编程
    一个commit引发的思考
    golang中判断两个slice是否相等
    c++性能测试工具:计算时间复杂度
    c++性能测试工具:google benchmark入门(二)
    使用vs2019进行Linux远程开发
    智能指针和二叉树(3):图解查找和删除
  • 原文地址:https://www.cnblogs.com/dadream/p/5029754.html
Copyright © 2011-2022 走看看