zoukankan      html  css  js  c++  java
  • docker-compose部署

    一、部署compose
    docker compose可以方便我们快捷高效地管理容器的启动、停止、重启等操作,它类似于linux下的shell脚本,基于yaml语法,在该文件里我们可以描述应用的架构,比如用什么镜像、数据卷、网络模式、监听端口等信息。我们可以在一个compose文件中定义一个多容器的应用(比如jumpserver),然后通过该compose来启动这个应用。
     
     
    1: 安装compose
    [root@host1 ~]# curl -L https://github.com/docker/compose/releases/download/1.17.0-rc1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
     
    2:给予权限
    [root@host1 ~]# chmod 755 !$
     
    3:查询是否安装成功
    [root@host1 ~]# docker-compose -v
    docker-compose version 1.17.0-rc1, build a0f95af
     
    二、compose用法
     
    语法:docker-compose 【参数】 【命令】
    示例:docker-compose -f docker-compos.yml logs
     
     
    1:查询版本信息
    说明: Compose区分Version 1和Version 2(Compose 1.6.0+,Docker Engine 1.10.0+)。Version 2支持更多的指令。Version 1没有声明版本默认是"version 1"。Version 1将来会被弃用。
    [root@host1 ~]# docker-compose version
    docker-compose version 1.17.0-rc1, build a0f95af
    docker-py version: 2.5.1
    CPython version: 2.7.13
    OpenSSL version: OpenSSL 1.0.1t 3 May 2016
     
    2:编写compose执行文件,后缀为yml
    说明:image是指定docker镜像、prots指定本地和容器映射的端口、networks指定容器调用网卡模式、volumes指定本地目录和容器的文件存放映射目录
    [root@host1 ~]# vim docker-compose.yml
    version: "2"
    services:
    nginx:
    image: nginx
    ports:
    - "81:80"
    networks:
    - "net1"
    volumes:
    - /data/:/data
    tomcat:
    image: tomcat
    ports:
    - "8081:8080"
    networks:
    - "net2"
    volumes:
    - /data/:/data1
    entrypoint: tail -f /etc/passwd
    networks:
    net1:
    driver: bridge
    net2:
    driver: bridge
     
    3:执行docker-compose文件
    说明:compose启动关闭命令方式有:start、stop,up、down;-f指定compose执行文件的路径,-d放置在后台启动
    [root@host1 ~]# docker-compose up -d
    Creating network "root_net2" with driver "bridge"
    Creating network "root_net1" with driver "bridge"
    Creating root_nginx_1 ...
    Creating root_tomcat_1 ...
    Creating root_nginx_1
    Creating root_tomcat_1 ... done
     
    4:加ps查看启动的任务,相当于docker ps命令,但是比docker ps信息输出比较直观
    [root@host1 ~]# docker-compose ps
    Name Command State Ports
    -------------------------------------------------------------------------------
    root_nginx_1 /bin/sh -c /usr/local/ngin ... Up 0.0.0.0:80->80/tcp
    root_tomcat_1 tail -f /etc/passwd Up 0.0.0.0:8080->8080/tcp
  • 相关阅读:
    phpstorm 2017 关掉变量提示 parameter name hints,改变打开方式
    RMAN-06496: must use the TO clause when the database is mounted or open
    FAL[client]: Failed to request gap sequence GAP
    搭建rac对单实例的MAA
    Linux下安装Oracle 10g(redhat 4)
    ora-01031:insufficient privileges
    ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
    checking for oracle home incompatibilities failed
    用root帐号切换其他帐号提示 su: warning: cannot change directory to /home/oracle: Permission denied
    an error occured during the file system check
  • 原文地址:https://www.cnblogs.com/douyi/p/11573784.html
Copyright © 2011-2022 走看看