docker centos7创建consul镜像以及用docker-compose启动镜像
直接贴代码了:
Dockfile:
- # Version 0.1
- FROM kuba_centos7
- MAINTAINER kuba si812cn@163.com
- # This is the release of Consul to pull in.
- ENV CONSUL_VERSION=1.4.0
- # This is the location of the releases.
- ENV HASHICORP_RELEASES=https://releases.hashicorp.com
- # Create a consul user and group first so the IDs get set the same way, even as
- # the rest of this may change over time.
- # Set up certificates, base tools, and Consul.
- RUN yum -y install ca-certificates gnupg libcap iputils \
- && yum clean all \
- && export CC=/opt/rh/devtoolset-6/root/usr/bin/gcc \
- && export CXX=/opt/rh/devtoolset-6/root/usr/bin/g++ \
- && groupadd consul \
- && useradd -r -g consul consul -s /bin/false \
- && mkdir -p /opt/software \
- && cd /opt/software/ \
- && gpg --keyserver pgp.mit.edu --recv-keys 91A6E7F85D05C65630BEF18951852D87348FFC4C \
- && wget ${HASHICORP_RELEASES}/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip \
- && wget ${HASHICORP_RELEASES}/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_SHA256SUMS \
- && wget ${HASHICORP_RELEASES}/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_SHA256SUMS.sig \
- && gpg --batch --verify consul_${CONSUL_VERSION}_SHA256SUMS.sig consul_${CONSUL_VERSION}_SHA256SUMS \
- && grep consul_${CONSUL_VERSION}_linux_amd64.zip consul_${CONSUL_VERSION}_SHA256SUMS | sha256sum -c \
- && mkdir /usr/local/consul \
- && unzip -o consul_${CONSUL_VERSION}_linux_amd64.zip -d /usr/local/bin \
- && consul --version \
- && mkdir -p /consul/data \
- && mkdir -p /consul/config \
- && chown -R consul:consul /consul \
- && echo 'hosts: files dns' > /etc/nsswitch.conf
- # Expose the consul data directory as a volume since there's mutable state in there.
- VOLUME /consul/data
- # Server RPC is used for communication between Consul clients and servers for internal
- # request forwarding.
- EXPOSE 8300
- # Serf LAN and WAN (WAN is used only by Consul servers) are used for gossip between
- # Consul agents. LAN is within the datacenter and WAN is between just the Consul
- # servers in all datacenters.
- EXPOSE 8301 8301/udp 8302 8302/udp
- # HTTP and DNS (both TCP and UDP) are the primary interfaces that applications
- # use to interact with Consul.
- EXPOSE 8500 8600 8600/udp
- # Consul doesn't need root privileges so we run it as the consul user from the
- # entry point script. The entry point script also uses dumb-init as the top-level
- # process to reap any zombie processes created by Consul sub-processes.
- ENTRYPOINT [consul]
- # By default you'll get an insecure single-node development server that stores
- # everything in RAM, exposes a web UI and HTTP endpoints, and bootstraps itself.
- # Don't use this configuration for production.
- CMD ["agent", "-dev", "-client", "0.0.0.0"]
docker build -t kuba_consul140 ./
中间如果失败,一般是网络问题,隔断时间重新执行一次就好
创建docker-compose文件
- # Copyright IBM Corp. All Rights Reserved.
- #
- # SPDX-License-Identifier: Apache-2.0
- #
- version: '2'
- services:
- consul140_0:
- image: kuba_consul140
- restart: always
- container_name: consul140_0
- volumes:
- - ./data/:/consul/data/
- ports:
- - 8300:8300
- - 8301:8301
- - 8301:8301/udp
- - 8302:8302
- - 8302:8302/udp
- - 8500:8500
- - 8600:8600
- - 8600:8600/udp
- entrypoint: consul
- command: agent -server -data-dir=/consul/data -config-dir=/consul/config -bootstrap -node=consul1140_0 -client=0.0.0.0
启动镜像:
docker-compose -f docker-compose-consul.yaml up -d 2>&1
查看镜像是否启动成功:
docker ps
查看consul
docker exec -t xxxx容器编号 consul members
docker centos7创建consul镜像以及用docker-compose启动镜像的更多相关文章
- Centos7创建支持ssh服务的docker镜像
如何在centos7中使用docker创建一个支持ssh连接的容器 1.拉取centos7.4镜像(由于7.4目前是最稳定的版本,所以推荐使用centos7.4) docker pull centos ...
- centos7创建docker tomcat镜像
1 准备宿主系统 准备一个 CentOS 7操作系统,具体要求如下: 必须是 64 位操作系统 建议内核在 3.8 以上 通过以下命令查看您的 CentOS 内核: 1 # uname -r 2 安装 ...
- docker Dockerfile 创建镜像
Docker 组件 1. docker client : docker的客户端 2. docker server : docker daemon的主要组成部分,接受用户通过docker client发 ...
- Centos7 创建本地 docker 仓库极其遇到的问题
环境安装: VirtualBox 安装 Centos7 安装 docker 1. 配置私有仓库和客户端地址 私有仓库:192.168.1.104 客户端:192.168.1.103 通过 Centos ...
- Docker 创建镜像、修改、上传镜像
Docker 创建镜像.修改.上传镜像 –创建镜像有很多方法,用户可以从 Docker Hub 获取已有镜像并更新,也可以利用本地文件系统创建一个. 一.创建镜像 创建镜像有很多方法,用户可以从 Do ...
- docker——Dockerfile创建镜像
写在前面: 继续docker的学习,昨天用docker成功跑了tomcat,但是在centos中镜像跑的容器手动装jdk和tomcat,今天学习用Dockerfile创建镜像,并在上面搭建java环境 ...
- 转 docker创建私有仓库和k8s中使用私有镜像
docker私有仓库建立 环境说明我们选取192.168.5.2做私有仓库地址yum install docker -y1.启动docker仓库端口服务 docker run -d -p 5000:5 ...
- Docker(十一)-Docker commit创建镜像
创建镜像有很多方法,用户可以从 Docker Hub 获取已有镜像并更新,也可以利用本地文件系统创建一个. 修改已有的镜像 查看已有的镜像: $ sudo docker images REPOSITO ...
- 两种方式创建支持SSH服务的docker镜像
方法一:基于commit命令创建 1.首先,从docker的源中查看我们需要的镜像,本案例中使用Ubuntu作为基础镜像. # federico @ linux in ~ [16:57:38] $ s ...
随机推荐
- 5种网络IO模型(有图,很清楚)
同步(synchronous) IO和异步(asynchronous) IO,阻塞(blocking) IO和非阻塞(non-blocking)IO分别是什么,到底有什么区别?这个问题其实不同的人给出 ...
- RobotFramework--环境安装1
1.RobotFramework RobotFramework 的架构是一个通用型的验收测试和验收测试驱动开发的自动化测试框架(ATDD).它 具有易于使用的表格来组织测试过程和测试数据. 3.1版本 ...
- input输入框只能输入正整数
<input type="text" value="1" onkeyup="if(this.value.length==1){this.valu ...
- .net core部署到Ubuntu碰到的问题
数据库连接的时候,会报错“MySql.Data.MySqlClient.MySqlException:“The host localhost does not support SSL connecti ...
- 001——使用composer安装ThinkPHP5
composer create-project topthink/think tp5 --prefer-dist
- ansible批量管理工具的搭建与简单的操作
ansible的安装 # [root@localhost ~]# cat /etc/redhat-release CentOS Linux release (Core) [root@localhost ...
- python读取与写入csv,txt格式文件
python读取与写入csv,txt格式文件 在数据分析中经常需要从csv格式的文件中存取数据以及将数据写书到csv文件中.将csv文件中的数据直接读取为dict类型和DataFrame是非常方便也很 ...
- 第八节 多态和Object类
多态的定义:某一类事物的多种存在形态 例子:学生类:包含学生A和学生B 学生A对象对应的类型是学生A类型:StudentA studentA = new StudentA; Student stude ...
- Linux shell基础知识(上)
Linux shell基础知识(上) 目录 一.shell介绍 二.命令历史 三.命令补全和别名 四.通配符 五.输入输出重定向 六.管道符和作业控制 七.shell变量 八.环境变量配置文件 九.b ...
- SQLserver触发器实现A表insert到B表
CREATE TABLE tab1(tab1_id varchar(11));CREATE TABLE tab2(tab2_id varchar(11)); 现在我们有两张表,要实现在A表里面inse ...