程序员潇然 发表于 2022-10-10 09:44:50

docker制作sentinel镜像 docker镜像制作

sentinel是阿里巴巴的流控工具,但是对于它本身的docker镜像,会发现提供的不是很新,有的时候需要自己制作。

### 工作路径

找地方建立工作路径

!(data/attachment/forum/202210/10/094126wjl5m5gkrjxfpapp.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "image.png")

### Dockerfile 创建

```bash
FROM java:8
ADD *.jar sentinel-dashboard.jar
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo '$TZ' > /etc/timezone
ENTRYPOINT ["java","-jar","-Dserver.port=8718","-Dcsp.sentinel.dashboard.server=127.0.0.1:8718","-Dproject.name=sentinel-dashboard","/sentinel-dashboard.jar"]
```

```html
#java 版本
FROM java:8
##挂载的docker卷
VOLUME /tmp
#前者是要操作的jar包后者自定义jar包名
ADD *.jar sentinel-dashboard.jar
#定义时区参数
ENV TZ=Asia/Shanghai
#设置时区
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo '$TZ' > /etc/timezone
#配置启动命令,-D表示设置JVM参数
ENTRYPOINT ["java","-jar","-Dserver.port=8080","-Dcsp.sentinel.dashboard.server=162.14.118.19.175:8080","-Dproject.name=sentinel-dashboard","/sentinel-dashboard.jar"]
```

### jar

上传jar包

!(data/attachment/forum/202210/10/094322nanafbb7far1ka11.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "image.png")


### 镜像制作

`docker build -t sentinel-server .`

!(data/attachment/forum/202210/10/094351v4f4c0eec9ifi40a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "image.png")


### 标签

!(data/attachment/forum/202210/10/094410pay9pygrayxexpuw.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "image.png")


### 运行

```bash
docker run \
--name sentinel-server1.8.4 \
-p 8718:8718 \
--restart=always \
--privileged=true \
-d sentinel-server:1.8.4
```


!(data/attachment/forum/202206/16/141330jha7st9soow8772i.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "common_log.png")
`转载务必注明出处:程序员潇然,疯狂的字节X,https://crazybytex.com/thread-197-1-1.html `
页: [1]
查看完整版本: docker制作sentinel镜像 docker镜像制作