# 使用 Ubuntu 作为基础镜像 FROM ubuntu:20.04 # 安装必要的软件 RUN apt-get update && apt-get install -y wget # 修改目录权限 RUN mkdir -p prometheus && chmod -R 777 prometheus # 下载 Prometheus RUN wget https://github.com/prometheus/prometheus/releases/download/v2.43.0/prometheus-2.43.0.linux-amd64.tar.gz && \ tar -xvzf prometheus-2.43.0.linux-amd64.tar.gz -C prometheus && \ rm prometheus-2.43.0.linux-amd64.tar.gz # 将 Prometheus 配置文件复制到容器中 COPY prometheus.yml /prometheus/prometheus.yml # 设置工作目录 WORKDIR /prometheus/prometheus-2.43.0.linux-amd64 # 暴露 Prometheus 默认端口 EXPOSE 9090 # 启动 Prometheus CMD ["./prometheus", "--config.file=/prometheus/prometheus.yml", "--storage.tsdb.path=/prometheus"]