Docker installation and deployment Sentinel Dashboard

1. Download the jar package

Official jar package download address: https://github.com/alibaba/Sentinel/releases
or click the link to jump directly to the download page
. Enter the link to download the version you need.

Download completed (I put them in one sentineldirectory here)

2. Write a Dockerfile (I do not use docker-compose deployment here)

sentinelCreate a file within the directory and Dockerfilefill in the following content:

#java 版本
FROM java:8
##挂载的docker卷
VOLUME /tmp

# 定义jar包名称
ENV JAR_FILE *.jar # 这里因为只有一个 jar 包,简便我就直接写 *.jar 了

# 拷贝 jar 包到容器内
COPY $JAR_FILE sentinel-dashboard.jar
# 定义时区参数
ENV TZ=Asia/Shanghai
# 设置时区
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo '$TZ' > /etc/timezone
# 配置启动命令
ENTRYPOINT ["java", "-jar", "/sentinel-dashboard.jar"]

3. Write build image & run container scripts

sentinelCreate a script in the directory, here I call itbuild-run.sh


# sh脚本不需要加上开头那行 !#bin/bash

# 构建镜像
docker build -t sentinel-dashboard:1.8.6 .

# 运行容器
docker run --name sentinel-dashboard -p 8080:8080 --restart=always --privileged=true -d sentinel-dashboard:1.8.6

4. Build start

The files in the final file directory are as follows:
Insert image description here

1. Give build-run.sh execution permissions

# 首先进入 sentinel 目录
chmod +x build-run.sh

2. Execute the script

sh build-run.sh # sh 脚本执行方式: sh ***.sh 

3. Wait for the image to be built & start the container

4. The container startup is completed

5. Verification

Open localhost:8080
and the default account and password aresentinel

Insert image description here

Here I have configured two microservices to see the effect

Insert image description here
Insert image description here

5. If you must use docker-compose, please refer to the following

# 参考链接:https://blog.51cto.com/chaim/4582366

# Compose 版本 Version 2支持更多的指令。Version 1将来会被弃用。
version: "3"

# 定义服务
services:

# 为project定义服务
  sentinel:
    image: bladex/sentinel-dashboard:1.7.1
    ports:
- 8858:8858
    environment:
# 是否开启登录鉴权,仅用于日常测试,生产上不建议关闭, 默认true
      auth.enabled: "true"
# 登录控制台的用户名,默认为 sentinel
      sentinel.dashboard.auth.username: admin
# 登录控制台的密码,默认为 sentinel
      sentinel.dashboard.auth.password: admin123
# 用于指定 Spring Boot 服务端 session 的过期时间,如 7200 表示 7200 秒;60m 表示 60 分钟,默认为 30 分钟;
      server.servlet.session.timeout: 7200
restart: always
    container_name: sentinel
    privileged: true

おすすめ

転載: blog.csdn.net/qq_17229141/article/details/134702917