新增:《Docker安装Consul》
This commit is contained in:
@@ -102,4 +102,8 @@ tags:
|
||||
- 在创建对象时,先写完后面 new Xxx() 部分,然后输入 .var + 回车:补全前面声明部分
|
||||
- 数组/Collection系列集合,.for + 回车:生成增强 for 语句
|
||||
- 数组/Collection系列集合,.fori + 回车:生成循环下标语句(Set集合不行)
|
||||
- 返回值,.return + 回车:生成 return 返回值; 语句
|
||||
- 返回值,.return + 回车:生成 return 返回值; 语句
|
||||
|
||||
## 浏览器
|
||||
|
||||
- Ctrl + 0:恢复页面默认缩放
|
60
docs/categories/fragments/2022/10/25/Docker安装Consul.md
Normal file
60
docs/categories/fragments/2022/10/25/Docker安装Consul.md
Normal file
@@ -0,0 +1,60 @@
|
||||
---
|
||||
title: Docker安装Consul
|
||||
author: 查尔斯
|
||||
date: 2022/10/25 22:00
|
||||
categories:
|
||||
- 杂碎逆袭史
|
||||
tags:
|
||||
- Consul
|
||||
- Docker
|
||||
- 容器
|
||||
showComment: false
|
||||
---
|
||||
|
||||
# Docker安装Consul
|
||||
|
||||
## 拉取镜像
|
||||
|
||||
::: warning 笔者说
|
||||
拉取镜像时需要明确镜像版本(Tag)。
|
||||
:::
|
||||
|
||||
不指定版本(Tag)就拉取镜像,那拉取下来的镜像版本(Tag)默认是 `latest`(最新的)。`latest` 会跟随 Docker Registry 中的记录变化,现在拉取下来的 `latest` 是 x1 版本,但隔了一段时间后你在其他机器上再拉取 `latest` 可能就是 x2 版本了。
|
||||
|
||||
笔者下面的步骤及配置也是基于指定版本的实践,大多数程序大多数情况下在相差不大的版本时可以直接参考。(当然了,即使是非 Docker 方式安装程序也是一样道理)
|
||||
|
||||
变化的版本,不利于生产环境部署的稳定。无论是后续在其他环境部署还是扩容集群等场景均要求根据架构要求指定好版本。
|
||||
|
||||
```shell
|
||||
docker pull consul:1.13.3
|
||||
```
|
||||
|
||||
## 运行容器
|
||||
|
||||
::: warning 笔者说
|
||||
**下方的配置,切记要根据个人实际情况来修改。**
|
||||
:::
|
||||
|
||||
- 是否端口映射?
|
||||
- 映射的话映射到宿主机哪个端口?
|
||||
- 是否挂载卷?
|
||||
- 挂载的话要挂载宿主机哪个目录?
|
||||
- 是否设置自启动?
|
||||
- 容器的名称
|
||||
- 镜像名称:版本
|
||||
- ......
|
||||
- 等自定义配置
|
||||
|
||||
```shell
|
||||
docker run -d \
|
||||
-p 18500:8500 \
|
||||
-v /opt/disk/consul/conf/:/consul/conf/ \
|
||||
-v /opt/disk/consul/data/:/consul/data/ \
|
||||
--restart=always \
|
||||
--name consul \
|
||||
consul:1.13.3
|
||||
```
|
||||
|
||||
## 验证
|
||||
|
||||
服务器开放好相应端口或设置好安全组后,访问 `http://宿主机IP:映射的端口` (例如按上方配置那就是:http://宿主机IP:18500)即可看到 Consul 界面。
|
Reference in New Issue
Block a user