如何使用码头工人的组成工具和配置高服务器

  

本文分享的是码头工人容器中组成编排工具和领事工具的使用,以及领事服务器的配置,希望大家根据这篇文章可以有所收获。

码头工人组成配置常用字段

字段描述构建dockerfile上下文指定dockerfile文件名构建镜像上下文路径形象指定镜像命令执行命令,覆盖默认命令容器名称指定容器名称,由于容器名称是唯一的,如果指定自定义名称,则无法scaledeploy指定部署和运行服务相关配置,只能在群模式使用环境添加环境变量网络加入网络港口暴露容器端口,与p相同,但端口不能低于60卷挂载宿主机路径或命令卷重启重启策略,默认不,总是,无故障,unless-stopedhostname容器主机名

码头工人组成常用命令

字段描述构建重新构建服务ps列出容器上创建和启动容器执行在容器里面执行命令规模指定一个服务容器启动数量上显示容器进程日志查看容器输出了删除容器,网络,数据卷和镜像停止/启动/重新启动停止/启动/重启服务

组合命令说明

基本的使用格式

 <代码> docker-compose[选项][命令][arg游戏……) 

docker-compose选项

 <代码>——冗长的输出更多调试信息
  ——版本打印版本并退出
  - f,文件文件使用特定的组合模板文件,默认为docker-compose.yml
  - p,项目名称名称指定项目名称,默认使用目录名称 

1,安装码头工人容器和组合编排工具

 <代码> [root@localhost ~] # yum安装- y \
  比;yum-utils \,,# #设置源工具
  比;device-mapper-persistent-data \,,# #映射工具
  比;lvm2,# #映射工具
  root@localhost ~ # yum-config-manager——add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  # #加载阿里云镜像源
  (root@localhost ~) # yum安装docker-ce - y, # #安装码头工人容器
  (root@localhost ~) # systemctl firewalld停止。服务,# #关闭防火墙
  (root@localhost ~) # setenforce 0
  (root@localhost ~) # systemctl开始码头工人,# #开启码头工人容器
  (root@localhost ~) # systemctl使码头工人,# #开机自启动
  (root@localhost ~) # ps辅助| grep码头工人,# #查看码头工人进程是否开启
  #三通/etc/docker/daemon. root@localhost ~json & lt; & lt; & # 39; eof # 39;,# #进行镜像加速
  比;{
  比;,“registry-mirrors": [“https://3a8s9zx5.mirror.aliyuncs.com"]
  比;}
  比;EOF
  {
  ,,,,“registry-mirrors": [“https://3a8s9zx5.mirror.aliyuncs.com"]
  }
  (root@localhost ~) # systemctl daemon-reload,# #重载守护进程
  (root@localhost ~) # systemctl重启码头工人,# #重启码头工人服务
  root@localhost ~ #山。cifs//192.168.100.100/LNMP-C7/mnt/密码root@//192.168.100.100/LNMP-C7:,
  (root@localhost ~) # cd/mnt/码头工人
  [root@localhost码头工人]# cp - p docker-compose/usr/bin/,
  # #将docker-compose复制到/usr/bin/目录下
  [root@localhost码头工人]# docker-compose - v,# #查看版本信息
  1.21.1 docker-compose版本,构建5 a3f1a3  

2,创建Nginx编排实例

 <代码> [root@localhost码头工人]# cd ~
  (root@localhost ~) # mkdir compose-nginx, # #创建工作目录
  root@localhost ~ # cd compose-nginx/[root@localhost compose-nginx] # mkdir nginx,# #创建Nginx的目录
  [root@localhost compose-nginx] # cd/nginx
  [root@localhost nginx] # vim运行。sh, # #编辑启动脚本
  # !/bin/bash/usr/local/nginx/sbin/nginx,# #启动Nginx服务
  [root@localhost nginx] # mkdir/abc
  [root@localhost nginx] #山。cifs//192.168.100.3/LNMP-C7/abc/密码root@//192.168.100.3/LNMP-C7:,
  [root@localhost nginx] # cp/abc/nginx-1.12.2.tar。广州。/,# #将Nginx的压缩包复制到当前目录下
  [root@localhost nginx] # vim Dockerfile, # #编写容器文件
  从centos: 7
  运行yum - y更新
  运行yum - y安装pcre-devel zlib-devel gcc gcc-c + +
  运行useradd - m - s/sbin/nologin nginx
  添加nginx-1.12.2.tar。广州/usr/local/src
  WORKDIR/usr/local/src
  WORKDIR nginx-1.12.2
  运行./configure \
  ——prefix=/usr/地方/nginx \
  ——用户=nginx \
  ——组=nginx \
  ——with-http_stub_status_module,,使,,制作安装
  ENV路径/usr/local/nginx/sbin: $路径
  80年公开
  443年公开
  运行回声“守护进程;“祝辞在/usr/地方/nginx/conf/nginx.conf
  添加运行。sh/run.sh
  运行chmod 755/run.sh
  CMD (“/run.sh")
  [root@localhost nginx] # cd . ./[root@localhost compose-nginx] # vim docker-compose。yml,# #创建构成模板脚本
  版本:& # 39;3 & # 39;,# #版本
  服务:,,,# #服务
  ,,nginx:
  ,,,,主机名:nginx, # #容器主机名
  ,,,,构建:
  ,,,,,背景:。/nginx, # #创建容器的文件路径
  ,,,,,dockerfile: dockerfile
  ,,,,港口:
  ,,,,,——1216:80大敌;# #映射端口
  ,,,,,,- 1217:443
  ,,,网络:大敌;
  ,,,,,——abc大敌;,,# #网络名称
  ,,,,数量:
  ,,,,,——。/wwwroot:/usr/地方/nginx/html,# #数据卷关联宿主站点目录
  网络:,,# #对外申明网络
  ,,美国广播公司(abc):
  [root@localhost compose-nginx] # docker-compose - f docker-compose。yml了-
  # #执行组成脚本开启,- d守护进程
  [root@localhost compose-nginx] # cd wwwroot/[root@localhost wwwroot] # vim index . html
  这是测试! ! !,# #编辑首页内容
  [root@localhost wwwroot] # yum安装树- y
  [root@localhost wwwroot] #树~,# #查看整个所需的内容结构/根
  ├──anaconda-ks.cfg
  ├──compose-nginx
  │,├──docker-compose。yml,# #编排模板
  │,├──nginx
  │,│,├──Dockerfile,# #容器脚本
  │,│,├──nginx-1.12.2.tar。广州,,# #安装包
  │,│,└──运行。sh, # #启动服务脚本
  │,└──wwwroot
  │,,,└──指数。html,null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null

如何使用码头工人的组成工具和配置高服务器