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 ...
随机推荐
- 重写console.log的一些理解
关于重写console.log的方式通常都是这样的: console.log = (function(oriLogFunc){ return function(str) { oriLogFunc.ca ...
- e1000e 网卡如遇到大包未线速问题解法
e1000e 网卡如遇到大包(>1280)未线速,把'DEFAULT_ITR'改为0, 不设中断频率上限试试 see@intel/e1000e/param.c/* Interrupt Throt ...
- Luffy之购物车页面搭建
前面已经将一些课程加入购物车中,并保存到了后端的redis数据库中,此时做购物车页面时,我们需要将在前端向后端发送请求,用来获取数据数据 购物车页面 1.首先后端要将数据构建好,后端视图函数如下代码: ...
- Java中使用HTTP阻塞式调用服务器API
应用场景:前端页面点击刷新,调用服务器A上Java接口,然后A调用服务器B的后台Python接口实时刷新后台数据库. 在这个场景中会涉及到两个问题:异步,Python服务器压力 (一)解决Python ...
- [poj P2482] Stars in Your Window
[poj P2482] Stars in Your Window Time Limit: 1000MS Memory Limit: 65536K Description Fleeting time ...
- SQL-47 如何获取emp_v和employees有相同的数据?
题目描述 存在如下的视图:create view emp_v as select * from employees where emp_no >10005;如何获取emp_v和employees ...
- Unable to load DLL 'api-ms-win-core-localization-l1-2-0.dll': 找不到指定的模块
asp.net mvc 4.6 发布到WinServer2008R2 SP1 提示 错误 Unable to load DLL 'api-ms-win-core-localization-l1-2-0 ...
- leetcode题解 200. Number of Islands(其实就是一个深搜)
题目: Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is s ...
- Selenium·自动化基础
date:2018505+2018506 day05+06mor 一.安装环境 1.cmd→pip install selenium 2.将浏览器驱动放入X:\Python27下(如chromedri ...
- django之Session、Cookie
Session ·Session存在于服务器端 ·Session的设置: request.session['name'] = value ·Session的获取: dic = request.sess ...