zoukankan      html  css  js  c++  java
  • [Docker6] Docker compose多容器运行与管理

    六、Docker compose

    docker compose就是通过yml文件来定义和运行多个容器docker应用程序的工具,三步过程就能跑起一个compose:

    • 定义应用程序的环境(yml中)
    • 定义组成应用程序的服务(docker-compose.yml)
    • docker-compose up启动整个应用程序

    6.1 安装docker compose

    依赖:docker engine

    # download the latest version
    sudo curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
    # excutable
    sudo chmod +x /usr/local/bin/docker-compose
    # check version
    docker-compose --version
    

    6.2 docker compose管理application lifestyle的command

    Define and run multi-container applications with Docker.
    
    Usage:
      docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...]
      docker-compose -h|--help
    
    Options:
      -f, --file FILE             Specify an alternate Compose file (default: docker-compose.yml)
      -p, --project-name NAME     Specify an alternate project name (default: directory name)
      --verbose                   Show more output
      --no-ansi                   Do not print ANSI control characters
      -v, --version               Print version and exit
      -H, --host HOST             Daemon socket to connect to
    
      --tls                       Use TLS; implied by --tlsverify
      --tlscacert CA_PATH         Trust certs signed only by this CA
      --tlscert CLIENT_CERT_PATH  Path to TLS certificate file
      --tlskey TLS_KEY_PATH       Path to TLS key file
      --tlsverify                 Use TLS and verify the remote
      --skip-hostname-check       Don't check the daemon's hostname against the name specified
                                  in the client certificate (for example if your docker host
                                  is an IP address)
      --project-directory PATH    Specify an alternate working directory
                                  (default: the path of the Compose file)
    
      build              Build or rebuild services
      bundle             Generate a Docker bundle from the Compose file
      config             Validate and view the compose file
      create             Create services
      down               Stop and remove containers, networks, images, and volumes
      events             Receive real time events from containers
      exec               Execute a command in a running container
      help               Get help on a command
      kill               Kill containers
      logs               View output from containers
      pause              Pause services
      port               Print the public port for a port binding
      ps                 List containers
      pull               Pulls service images
      push               Push service images
      restart            Restart services
      rm                 Remove stopped containers
      run                Run a one-off command
      scale              Set number of containers for a service
      start              Start services
      stop               Stop services
      unpause            Unpause services
      up                 Create and start containers
      version            Show the Docker-Compose version information
    

    6.3 create a demo

    • Create a directory for the project
    • create application
    • Create another file called requirements.txt in your project directory and paste this in
    • Create a Dockerfile
    • Define services in a Compose file (docker-compose.yml)
    • Build and run your app with Compose
    • access your application
  • 相关阅读:
    机器学习模型之逻辑回归
    机器学习模型之决策树
    机器学习模型之朴素贝叶斯
    机器学习模型之KNN算法
    Gradle系列之构建脚本基础
    Gradle系列之Groovy基础篇
    Gradle系列之初识Gradle
    Bitmap之内存缓存和磁盘缓存详解
    Bitmap之位图采样和内存计算详解
    WebView中Java与JavaScript的交互
  • 原文地址:https://www.cnblogs.com/xuelong3/p/8006528.html
Copyright © 2011-2022 走看看