容器技术|Docker三剑客之docker-compose

三剑客简介

docker-machine

docker技术是基于Linux内核的cgroup技术实现的,那么问题来了,在非Linux平台上是否就不能使用docker技术了呢?答案是可以的,不过显然需要借助虚拟机去模拟出Linux环境来。

docker-machine就是docker公司官方提出的,用于在各种平台上快速创建具有docker服务的虚拟机的技术,甚至可以通过指定driver来定制虚拟机的实现原理(一般是virtualbox)。

docker-compose

docker镜像在创建之后,往往需要自己手动pull来获取镜像,然后执行run命令来运行。当服务需要用到多种容器,容器之间又产生了各种依赖和连接的时候,部署一个服务的手动操作是令人感到十分厌烦的。

dcoker-compose技术,就是通过一个.yml配置文件,将所有的容器的部署方法、文件映射、容器连接等等一系列的配置写在一个配置文件里,最后只需要执行docker-compose up命令就会像执行脚本一样的去一个个安装容器并自动部署他们,极大的便利了复杂服务的部署。

docker-swarm

swarm是基于docker平台实现的集群技术,他可以通过几条简单的指令快速的创建一个docker集群,接着在集群的共享网络上部署应用,最终实现分布式的服务。

docker-compose 的工作流程

使用Compose仅需要三步:

1、用一个定义你的应用程序的环境,Dockerfile这样它就可以在任何地方再现。

2、定义组成您的应用程序的服务,docker-compose.yml 以便它们可以在隔离的环境中一起运行。

3、运行docker-compose up和撰写启动并运行您的整个应用程序。

参考文章:https://docs.docker.com/compose/overview/

docker-compose安装布署

[[email protected] ~]# curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   617    0   617    0     0    396      0 --:--:--  0:00:01 --:--:--   397
100 10.3M  100 10.3M    0     0   678k      0  0:00:15  0:00:15 --:--:-- 1876k
[[email protected] ~]# chmod +x /usr/local/bin/docker-compose
[[email protected] ~]# docker-compose --version
docker-compose version 1.21.2, build a133471

docker-compose管理命令介绍

Compose具有管理应用程序整个生命周期的命令:

  • 启动,停止和重建服务
  • 查看正在运行的服务的状态
  • 流式传输运行服务的日志输出
  • 在服务上运行一次性命令
[[email protected] ~]# docker-compose --help
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
  --log-level LEVEL           Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  --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
  --project-directory PATH    Specify an alternate working directory
                              (default: the path of the Compose file)
  --compatibility             If set, Compose will attempt to convert deploy
                              keys in v3 files to their non-Swarm equivalent

Commands:
  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
  images             List images
  kill               Kill containers
  logs               View output from containers
  pause              Pause services
  port               Print the public port for a port binding
  ps                 List containers
  pull               Pull 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
  top                Display the running processes
  unpause            Unpause services
  up                 Create and start containers
  version            Show the Docker-Compose version information

docker-compose 运行时是需要指定service名称,可以同时指定多个,也可以不指定。不指定时默认就是对配置文件中所有的service执行命令。

-f #用于指定配置文件

-p #用于指定项目名称

docker-compose build

用来创建或重新创建服务使用的镜像

docker-compose build service_a

创建一个镜像名叫service_a

docker-compose kill

用于通过容器发送SIGKILL信号强行停止服务

docker-compose logs

显示service的日志信息

docker-compose pause/unpause

docker-compose pause #暂停服务

docker-compose unpause #恢复被暂停的服务

docker-compose port

用于查看服务中的端口与物理机的映射关系

docker-compose port nginx_web 80

查看服务中80端口映射到物理机上的那个端口

dokcer-compose ps

用于显示当前项目下的容器

注意,此命令与docker ps不同作用,此命令会显示停止后的容器(状态为Exited),只征对某个项目。

docker-compose pull

用于拉取服务依赖的镜像

docker-compose restart

用于重启某个服务中的所有容器

docker-compose restart service_name

只有正在运行的服务可以使用重启命令,停止的服务是不可以重启

docker-compose rm

删除停止的服务(服务里的容器)

-f #强制删除

-v #删除与容器相关的卷(volumes)

docker-compose run

用于在服务中运行一个一次性的命令。这个命令会新建一个容器,它的配置和srvice的配置相同。

但两者之间还是有两点不同之处

1、run指定的命令会直接覆盖掉service配置中指定的命令

2、run命令启动的容器不会创建在service配置中指定的端口,如果需要指定使用--service-ports指定

docker-compose start/stop

docker-compose start 启动运行某个服务的所有容器

docker-compose stop 停止运行某个服务的所有容器

docker-compose scale

指定某个服务启动的容器个数

[[email protected] ~]# docker-compose scale --help
Numbers are specified in the form `service=num` as arguments.
For example:

    $ docker-compose scale web=2 worker=3

This command is deprecated. Use the up command with the `--scale` flag
instead.

Usage: scale [options] [SERVICE=NUM...]

Options:
  -t, --timeout TIMEOUT      Specify a shutdown timeout in seconds.
                             (default: 10)

docker-compose配置文件实例

一个docker-compose.yml的实例文件如下

version: "3"
services:
  nginx:
    container_name: web-nginx
    image: nginx:latest
    restart: always
    ports:
      - 80:80
    volumes:
    - ./webserver:/webserver
    - ./nginx/nginx.conf:/etc/nginx/nginx.conf

下面将配置文件做个简单的解释说明

docker-compose的配置文件是一个.yml格式的文件
第一部分
version: "3"  #指定语法的版本
第二部分
services:     #定义服务
  nginx:      #服务的名称,-p参数后接服务名称
    container_name: web-nginx    #容器的名称
    image: nginx:latest          #镜像
    restart: always
    ports:                       #端口映射
      - 80:80
第三部分
volumes:       #物理机与容器的磁盘映射关系
    - ./webserver:/webserver
    - ./nginx/nginx.conf:/etc/nginx/nginx.conf

整体的目录结构如下

[[email protected] docker]# tree ./
./
├── docker-compose.yml
├── nginx
│?? └── nginx.conf
└── webserver
    └── index.html

2 directories, 3 files

配置文件如下

[[email protected] docker]# cat webserver/index.html
welcome to nginx server!!!!!!!!!
[[email protected] docker]# cat nginx/nginx.conf
#user  nginx;
worker_processes  1;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘
                      ‘$status $body_bytes_sent "$http_referer" ‘
                      ‘"$http_user_agent" "$http_x_forwarded_for"‘;

    access_log  /var/log/nginx/access.log  main;
    client_max_body_size 10m;
    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

server {
    listen       80;
    server_name  localhost;

    location / {
        root   /webserver;
        index  index.html index.htm;
    }

}
    include /etc/nginx/conf.d/*.conf;
}

使用命令启动容器

[[email protected] docker]# docker-compose up -d
Pulling nginx (nginx:1.14)...
Trying to pull repository docker.io/library/nginx ...
1.14: Pulling from docker.io/library/nginx
f2aa67a397c4: Already exists
6160d1ac49e9: Pull complete
046b67408776: Pull complete
Digest: sha256:85ab7c44474df01422fe8fdbf9c28e497df427e8a67ce6d47ba027c49be4bdc6
Status: Downloaded newer image for docker.io/nginx:1.14
Creating nginx-server ... done
[[email protected] docker]# lsof -i :80
COMMAND   PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
docker-pr 891 root    4u  IPv6 1187080      0t0  TCP *:http (LISTEN)
[[email protected] docker]# docker ps |grep nginx
07ca899cc44b   nginx:1.14   "nginx -g ‘daemon ..."   29 seconds ago  Up 28 seconds  0.0.0.0:80->80/tcp  nginx-server
#如果启动时不指定里面的服务名称,就是直接启动配置文件里所有的服务

浏览器测试是否正常访问

然后我们修改相应的首页文件如下

[[email protected] docker]# cat webserver/index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>welcome to nginx web stie</title>
</head>
<body>
   <h2>欢迎来nginx站点</h2>
</body>
</html>

再次打开浏览器查看效果

#是不是非常的方便

使用Docker-Compose部署nginx代理Tomcat集群,实现负载均衡

大体步骤分为以下四步

1、下载所需的文件tomcat,jdk

2、编写dockerfile来布署tomcat与java环境,生成镜像文件

3、编写docker-compose.yml配置文件,启动所有容器服务

4、测试负载均衡

具体配置文件如下

#整个目录结构
[[email protected] java]# tree ./
./
├── docker-compose.yml
├── etc
│   └── localtime
├── nginx
│   └── nginx.conf
├── tomcat
│   ├── apache-tomcat-8.5.31.tar.gz
│   ├── Dockerfile
│   └── jdk-8u144-linux-x64.tar.gz
└── webserver
    ├── tomcatA
    │   └── index.jsp
    └── tomcatB
        └── index.jsp

6 directories, 8 files

两个测试首页文件

[[email protected] java]# cat webserver/tomcatA/index.jsp
welcome to tomcat-A server
[[email protected] java]# cat webserver/tomcatB/index.jsp
welcome to tomcat-B server

配置文件

[[email protected] java]# cat docker-compose.yml
version: "3"
services:
  nginx:
    image: nginx:1.14
    restart: always
    ports:
      - 80:80
    links:
      - tomcat1:tomcat1
      - tomcat2:tomcat2
    volumes:
      - ./webserver:/webserver
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./etc/localtime:/etc/localtime
    depends_on:
      - tomcat1
      - tomcat2

  tomcat1:
    hostname: tomcat1
    build: ./tomcat
    volumes:
      - ./webserver/tomcatA:/usr/local/apache-tomcat-8.5.31/webapps/ROOT
      - ./etc/localtime:/etc/localtime

  tomcat2:
    hostname: tomcat2
    build: ./tomcat
    volumes:
      - ./webserver/tomcatB:/usr/local/apache-tomcat-8.5.31/webapps/ROOT
      - ./etc/localtime:/etc/localtime

安装JAVA环境

[[email protected] java]# cat tomcat/Dockerfile
FROM centos

ADD jdk-8u144-linux-x64.tar.gz /usr/local
ENV JAVA_HOME /usr/local/jdk1.8.0_144
ADD apache-tomcat-8.5.31.tar.gz /usr/local

EXPOSE 8080
ENTRYPOINT ["/usr/local/apache-tomcat-8.5.31/bin/catalina.sh", "run"]

启动所有容器服务

[[email protected] java]# docker-compose up
Building tomcat1
Step 1/6 : FROM centos
Trying to pull repository docker.io/library/centos ...
latest: Pulling from docker.io/library/centos
7dc0dca2b151: Pull complete
Digest: sha256:b67d21dfe609ddacf404589e04631d90a342921e81c40aeaf3391f6717fa5322
Status: Downloaded newer image for docker.io/centos:latest
 ---> 49f7960eb7e4
Step 2/6 : ADD jdk-8u144-linux-x64.tar.gz /usr/local
 ---> 8c9e14062a24
Removing intermediate container a499940235ac
Step 3/6 : ENV JAVA_HOME /usr/local/jdk1.8.0_144
 ---> Running in cefedfd97f61
 ---> 12528cd5a517
Removing intermediate container cefedfd97f61
Step 4/6 : ADD apache-tomcat-8.5.31.tar.gz /usr/local
 ---> 246fa08bea1c
Removing intermediate container a1aaaa2bf0b8
Step 5/6 : EXPOSE 8080
 ---> Running in 87c4b41f3c1e
 ---> fd207f27b830
Removing intermediate container 87c4b41f3c1e
Step 6/6 : ENTRYPOINT /usr/local/apache-tomcat-8.5.31/bin/catalina.sh run
 ---> Running in 9adaed8e3ab9
 ---> b6fc6d3925f7
Removing intermediate container 9adaed8e3ab9
Successfully built b6fc6d3925f7
WARNING: Image for service tomcat1 was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Building tomcat2
Step 1/6 : FROM centos
 ---> 49f7960eb7e4
Step 2/6 : ADD jdk-8u144-linux-x64.tar.gz /usr/local
 ---> Using cache
 ---> 8c9e14062a24
Step 3/6 : ENV JAVA_HOME /usr/local/jdk1.8.0_144
 ---> Using cache
 ---> 12528cd5a517
Step 4/6 : ADD apache-tomcat-8.5.31.tar.gz /usr/local
 ---> Using cache
 ---> 246fa08bea1c
Step 5/6 : EXPOSE 8080
 ---> Using cache
 ---> fd207f27b830
Step 6/6 : ENTRYPOINT /usr/local/apache-tomcat-8.5.31/bin/catalina.sh run
 ---> Using cache
 ---> b6fc6d3925f7
Successfully built b6fc6d3925f7
WARNING: Image for service tomcat2 was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Pulling nginx (nginx:1.14)...
Trying to pull repository docker.io/library/nginx ...
1.14: Pulling from docker.io/library/nginx
f2aa67a397c4: Already exists
6160d1ac49e9: Pull complete
046b67408776: Pull complete
Digest: sha256:85ab7c44474df01422fe8fdbf9c28e497df427e8a67ce6d47ba027c49be4bdc6
Status: Downloaded newer image for docker.io/nginx:1.14
Creating java_tomcat2_1 ... done
Creating java_tomcat1_1 ... done
Creating java_nginx_1   ... done

查看启动情况

[[email protected] java]# docker-compose ps
     Name                   Command               State         Ports
----------------------------------------------------------------------------
java_nginx_1     nginx -g daemon off;             Up      0.0.0.0:80->80/tcp
java_tomcat1_1   /usr/local/apache-tomcat-8 ...   Up      8080/tcp
java_tomcat2_1   /usr/local/apache-tomcat-8 ...   Up      8080/tcp  

检测负载均衡

[[email protected] java]# curl http://localhost
welcome to tomcat-A server
[[email protected] java]# curl http://localhost
welcome to tomcat-B server
[[email protected] java]# curl http://localhost
welcome to tomcat-A server
[[email protected] java]# curl http://localhost
welcome to tomcat-B server
浏览器访问测试负载均衡

查看日志输出信息
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:33 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:34 +0000] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:34 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:36 +0000] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:36 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:36 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:37 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:37 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:37 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:37 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:38 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:38 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:38 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:38 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:38 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:14:39 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"
nginx_1    | 172.19.0.1 - - [08/Jun/2018:02:18:30 +0000] "GET / HTTP/1.1" 200 27 "-" "curl/7.29.0" "-"
nginx_1    | 172.19.0.1 - - [08/Jun/2018:02:18:31 +0000] "GET / HTTP/1.1" 200 27 "-" "curl/7.29.0" "-"
nginx_1    | 172.19.0.1 - - [08/Jun/2018:02:18:32 +0000] "GET / HTTP/1.1" 200 27 "-" "curl/7.29.0" "-"
nginx_1    | 172.19.0.1 - - [08/Jun/2018:02:18:33 +0000] "GET / HTTP/1.1" 200 27 "-" "curl/7.29.0" "-"
nginx_1    | 192.168.22.170 - - [08/Jun/2018:02:19:32 +0000] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" "-"

?著作权归作者所有:来自作者民工哥的原创作品,如需转载,请注明出处,否则将追究法律责任

原文地址:https://www.cnblogs.com/youkanyouxiao/p/9834786.html

时间: 2024-10-10 08:30:31

容器技术|Docker三剑客之docker-compose的相关文章

GIS+=地理信息+容器技术(4)——Docker执行

-------------------------------------------------------------------------------------- Blog:    http://blog.csdn.net/chinagissoft QQ群:16403743 宗旨:专注于"GIS+"前沿技术的研究与交流,将云计算技术.大数据技术.容器技术.物联网与GIS进行深度融合.探讨"GIS+"技术和行业解决方式 转载说明:文章同意转载.但必须以链接方

docker——三剑客之Docker Compose

编排(Orchestration)功能是复杂系统实现灵活可操作性的关键.特别是在Docker应用场景中,编排意味着用户可以灵活的对各种容器资源实现定义和管理. 作为Docker官方编排工具,Compose的重要性不言而喻,它可以让用户通过编写一个简单模板文件,快速地创建和管理基于Docker容器地应用集群. Compose项目是Docker官方的开源项目,负责实现对Docker容器的快速编排.从功能上看,跟OpenStack中的Heat十分相似.Compose定位是"定义和运行多个Docker容

docker——三剑客之Docker swarm

Docker Swarm是Docker官方的三剑客项目之一,提供Docker容器集群服务,是Docker官方对容器云生态进行支持的核心方案.使用它,用户可以将多个Docker主机封装为单个大型的虚拟Docker主机,快速打造一套容器云平台. Docker Swarm是Docker公司推出的官方容器集群平台,基于Go语言实现.目前,包括Rackspace在内的许多平台都采用了Swarm,用户很容易在AWS等公有云平台使用Swarm. Swarm的前身是Beam项目和libswarm项目,首个正式版

docker——三剑客之Docker Machine

Docker Machine是Docker官方三剑客项目之一,负责使用Docker的第一步,在多种平台上快速安装Docker环境.它支持多种平台,让用户在很短时间内搭建一套Docker主机集群. Machine项目是Docker官方的开源项目,负责实现对Docker主机本身进行管理.Machine项目主要由GO编写,用户可以在本地任意指定被Machine管理的Docker主机,并对其进行操作.Machine定位是"在本地或者云环境中创建Docker主机" Docker Machine是

docker三剑客之docker compose

compose环境变量 以DOCKER_开头的变量和用来配置Docker命令行客户端的使用一样,如果使用boot2docker,${boot2dockershellinit}将会设置他们为正确的值 compose环境变量: COMPOSE_PROJECT_NAME: 设置compose的项目名称,默认是当前工作目录(docker-compose.yml文件所在目录)的名字 compose会为每一个启动的容器前添加项目名称.例如一个名称为proj的项目,其中的一个web容器,名称可能为proj_w

docker三剑客之一docker compose

compose有两个重要的概念: 服务(service):一个应用的容器,实际上可以包括若干运行相同镜像的容器实例 项目(project):由一组关联的应用容器组成的一个完整业务单元,在docker-compose.yml文件中定义 compose默认管理对象是项目,通过子命令对项目中的一组容器进行便捷地生命周期管理 安装 pip安装,下载编译好的二进制文件,直接运行在docker容器中三种方案: pip安装: apt-get install python-pip -y pip install

docker三剑客之docker swarm

Swarm是什么 Swarm这个项目名称特别贴切.在Wiki的解释中,Swarm behavior是指动物的群集行为.比如我们常见的蜂群,鱼群,秋天往南飞的雁群都可以称作Swarm behavior. 安装 1.下载镜像 docker pull swarm docker run --rm swarm -v 2.配置节点 docker主机在加入swarm集群前,要进行配置,添加docker daemon的网络监听,例如,在启动docker daemon的时候通过-H参数: sudo docker

Docker 三剑客之Docker Swarm

Docker Swarm 介绍 创建Docker Swarm集群 1.使用docker machine ssh连接到想要成为manager node的那台docker宿主机上. $ docker-machine ssh manager1 2.执行下面的命令,创建一个swarm集群. docker swarm init --advertise-addr <MANAGER-IP> 例如: # docker swarm init --advertise-addr 43.241.208.252 Swa

每天5分钟玩转容器技术 整理目录

原 写在最前面 - 每天5分钟玩转容器技术(1) 容器生态系统 - 每天5分钟玩转容器技术(2) 容器生态系统 (续) - 每天5分钟玩转容器技术(3) 运行第一个容器 - 每天5分钟玩转容器技术(4) [视频]运行第一个容器 - 每天5分钟玩转容器技术(5) 容器 What, Why, How - 每天5分钟玩转容器技术(6) Docker 架构详解 - 每天5分钟玩转容器技术(7) Docker 组件如何协作?- 每天5分钟玩转容器技术(8) 最小的镜像 - 每天5分钟玩转容器技术(9) b