FROM registry.cn-hangzhou.aliyuncs.com/depl/alpine:3.16.2LABEL image.authors="geray" \image.description="Application packaged by Geray" \image.ref.name="alpine-3.16.2" \image.title="prometheus" \image.vendor="VMware, Inc." \image.version="2.36.1"COPY prometheus-2.36.1.linux-amd64.tar.gz /RUN mkdir /opt/prometheusENV PROMETHEUS_MAJOR=2 \PROMETHEUS_VERSION=3.16.1 \PROMETHEUS_HOME="/opt/prometheus"RUN tar -zxvf /prometheus-2.36.1.linux-amd64.tar.gz -C /opt/prometheus --strip-components 1 && \rm -rf /prometheus-2.36.1.linux-amd64.tar.gz && \mkdir /opt/prometheus/conf && \mkdir /opt/prometheus/data && \mkdir /opt/prometheus/bin && \mv ${PROMETHEUS_HOME}/prometheus.yml ${PROMETHEUS_HOME}/conf/ && \mv ${PROMETHEUS_HOME}/prometheus ${PROMETHEUS_HOME}/bin/ && \chown -R 1001:1001 /opt/prometheusENV PATH="/opt/prometheus/bin:$PATH"VOLUME ${PROMETHEUS_HOME}/confVOLUME ${PROMETHEUS_HOME}/dataWORKDIR ${PROMETHEUS_HOME}EXPOSE 9090USER 1001#ENTRYPOINT [ "prometheus" ]CMD [ "prometheus", \"--config.file=./conf/prometheus.yml", \"--storage.tsdb.path=./data", \"--web.console.libraries=./console_libraries", \"--web.enable-lifecycle", \"--web.console.templates=./consoles" ]
- 上面构建的镜像是 298MB ,如果使用
alpine:3.16.2作为基础镜像是 296MB - 这里使用的是我的基础镜像添加了时区所以打了2m
docker build -t registry.cn-hangzhou.aliyuncs.com/depl/prometheus:2.36.1 .docker push registry.cn-hangzhou.aliyuncs.com/depl/prometheus:2.36.1docker tag registry.cn-hangzhou.aliyuncs.com/depl/prometheus:2.36.1 geray/prometheus:2.36.1docker push geray/prometheus:2.36.1
部署
docker run -d --restart always\-p 9090:9090 \--name prometheus \-v $PWD/prometheus.yml:/opt/prometheus/conf/prometheus.yml \registry.cn-hangzhou.aliyuncs.com/depl/prometheus:2.36.1
