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 ...
随机推荐
- 7.2 GRASP原则二:信息专家 Information Expert
2.GRASP原则二:信息专家 Information Expert What is a general principle of assigning responsibility to obje ...
- 『流畅的Python』第12章:继承的优缺点
- VMware 虚拟机centos下链接网络配置
1.点击Network Adapter 设置如下图所示,首先我们在虚拟机中将网络配置设置成NAT, 2.计算机右键->管理->服务和应用程序->服务,启动如下两个服务 3.在etc/ ...
- mysql和mariadb支持insert delayed的问题
分析一个开源项目,往数据库里添加日志,为了避免写入日志信息影响正常业务,日志的插入方式采用了insert delayed的方式. 打印其数据库语句,复制到mysql执行报如下错误: ERROR 161 ...
- Django的下载与项目的创建
一.Django的下载安装 Django官网下载页面 二.DOS窗口下的django项目从创建和启动 1. DOS窗口下载Django pip3 install django==1.11.9 2.DO ...
- 在Tomcat中部署Web项目的操作方法,maven项目在Tomcat里登录首页报404
maven项目在Tomcat里登录首页报404, 解决:编辑conf/server.xml进行配置<Host>里的<Context>标签里的path. <Context ...
- python中字符串格式化
username='小黑'age=18high=1.88s2='欢迎%s,年龄是%d,身高是%.2f'%(username,age,high)#%s是通用的,%d就必须传整数,%f就必须是小数,想保留 ...
- librdkafka安装和php扩展php-rdkafka安装
1.安装librdkafka mac下 brew install librdkafka linux下 git clone https://github.com/edenhill/librdkafk ...
- java 集合之set。
Set具有与Collection完全一样的接口,因此没有任何额外的功能,不象前面有两个不同的List.实际上Set就是Collection,只是行为不同.(这是继承与多态思想的典型应用:表现不同的行为 ...
- SharePoint Framework 基于团队的开发(一)
博客地址:http://blog.csdn.net/FoxDave SharePoint Framework是新的用来构建SharePoint自定制的开发模型,它专注于客户端开发并用热门的开源工具gu ...