推荐把外网地址替换为国内高速镜像
# 替换源地址
http://dl-cdn.alpinelinux.org/alpine === https://mirrors.aliyun.com/alpine
https://repo1.maven.org/maven2 ===== https://maven.aliyun.com/repository/public
# go install 代理 proxy.golang.org
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
# yum镜像
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# docker镜像
https://hub.daocloud.io/
https://7iw3ne9w.mirror.aliyuncs.com/
http://hub-mirror.c.163.com/
# npm镜像
npm config set registry https://registry.npm.taobao.org
# yarn镜像
yarn config set registry https://registry.npm.taobao.org -g
yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g
# 设置APK加速 --repository ${ALPINE_REPO_URL}/edge/community/
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
Docker常用命令
# 停止所有的容器
docker stop $(docker ps -aq)
# 删除所有的容器
docker-compose rm --stop
# 删除所有的镜像
docker-compose down --rmi all
# 删除容器
docker rm -f 容器名称
# 删除镜像
docker rmi 镜像ID
# docker镜像打包
docker save 镜像ID -o 包名.tar
# 下载镜像
docker pull 镜像名称:tag版本
# d导入镜像
docker load -i 包名.tar
# 镜像tag重命名
docker tag thatName:thatTag thisName:thisTag
# 构建本地的镜像
docker build -t kafka-kafka:v1 -f Dockerfile ./
# 基本运行样式
docker run -d --name zookeeper -p 2181:2181 wurstmeister/zookeeper:tag
#查看容器日志(根据的容器名 --docker run —d 容器名)
docker logs <container name>
# 删除和停止容器
docker rm -f b7ee9987e6cb6881cad0e4bf09b9a7f9095003bbe5d67ff36fb2118b946478dd
# 创建docker通讯网络
docker network create datahub_network
# 指定运行脚本服务配置
docker-compose -f docker-compose.yml up -d
示例
外网的开源项目:DockerFile
# Defining environment
ARG APP_ENV=prod
FROM golang:1-alpine3.18 AS binary
ENV DOCKERIZE_VERSION v0.6.1
WORKDIR /go/src/github.com/jwilder
RUN apk --no-cache --update add openssl git tar curl
WORKDIR /go/src/github.com/jwilder/dockerize
RUN go install github.com/jwilder/dockerize@$DOCKERIZE_VERSION
FROM alpine:3 AS base
# Upgrade Alpine and base packages
ENV JMX_VERSION=0.18.0
# PFP-260: Upgrade Sqlite to >=3.28.0-r0 to fix https://security.snyk.io/vuln/SNYK-ALPINE39-SQLITE-449762
RUN apk --no-cache --update-cache --available upgrade \
&& apk --no-cache add curl bash coreutils gcompat sqlite libc6-compat java-snappy \
&& apk --no-cache add openjdk11-jre-headless --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community \
&& curl -sS https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-runner/9.4.46.v20220331/jetty-runner-9.4.46.v20220331.jar --output jetty-runner.jar \
&& curl -sS https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-jmx/9.4.46.v20220331/jetty-jmx-9.4.46.v20220331.jar --output jetty-jmx.jar \
&& curl -sS https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util/9.4.46.v20220331/jetty-util-9.4.46.v20220331.jar --output jetty-util.jar \
&& wget --no-verbose https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.24.0/opentelemetry-javaagent.jar \
&& wget --no-verbose https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/${JMX_VERSION}/jmx_prometheus_javaagent-${JMX_VERSION}.jar -O jmx_prometheus_javaagent.jar \
&& cp /usr/lib/jvm/java-11-openjdk/jre/lib/security/cacerts /tmp/kafka.client.truststore.jks
COPY --from=binary /go/bin/dockerize /usr/local/bin
ENV LD_LIBRARY_PATH="/lib:/lib64"
FROM base as prod-install
COPY datahub-upgrade.jar /datahub/datahub-upgrade/bin/
COPY metadata-models/src/main/resources/entity-registry.yml /datahub/datahub-gms/resources/entity-registry.yml
FROM base as dev-install
# Dummy stage for development. Assumes code is built on your machine and mounted to this image.
# See this excellent thread https://github.com/docker/cli/issues/1134
FROM ${APP_ENV}-install as final
RUN addgroup -S datahub && adduser -S datahub -G datahub
USER datahub
ENTRYPOINT ["java", "-jar", "/datahub/datahub-upgrade/bin/datahub-upgrade.jar"]
修改镜像地址
# Defining environment
ARG APP_ENV=prod
# Defining custom repo urls for use in enterprise environments. Re-used between stages below.
ARG ALPINE_REPO_URL=https://mirrors.aliyun.com/alpine
ARG GITHUB_REPO_URL=https://github.com
ARG MAVEN_CENTRAL_REPO_URL=https://maven.aliyun.com/repository/public
FROM golang:1-alpine3.18 AS binary
# Re-declaring arg from above to make it available in this stage (will inherit default value)
ARG ALPINE_REPO_URL
ENV DOCKERIZE_VERSION v0.6.1
WORKDIR /go/src/github.com/jwilder
# Optionally set corporate mirror for apk
RUN if [ "${ALPINE_REPO_URL}" != "https://mirrors.aliyun.com/alpine" ] ; then sed -i "s#https://mirrors.aliyun.com/alpine#${ALPINE_REPO_URL}#g" /etc/apk/repositories ; fi
RUN apk --no-cache --update add openssl git tar curl
WORKDIR /go/src/github.com/jwilder/dockerize
# 设置代理
RUN go env -w GO111MODULE=on
RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go install github.com/jwilder/dockerize@$DOCKERIZE_VERSION
FROM alpine:3.18 AS base
# Re-declaring args from above to make them available in this stage (will inherit default values)
ARG ALPINE_REPO_URL
ARG GITHUB_REPO_URL
ARG MAVEN_CENTRAL_REPO_URL
# Optionally set corporate mirror for apk
RUN if [ "${ALPINE_REPO_URL}" != "https://mirrors.aliyun.com/alpine" ] ; then sed -i "s#https://mirrors.aliyun.com/alpine#${ALPINE_REPO_URL}#g" /etc/apk/repositories ; fi
# 设置APK加速 --repository ${ALPINE_REPO_URL}/edge/community/
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# Upgrade Alpine and base packages
ENV JMX_VERSION=0.18.0
# PFP-260: Upgrade Sqlite to >=3.28.0-r0 to fix https://security.snyk.io/vuln/SNYK-ALPINE39-SQLITE-449762
RUN apk --no-cache --update-cache --available upgrade \
&& apk --no-cache add curl bash coreutils gcompat sqlite libc6-compat java-snappy \
&& apk --no-cache add openjdk11-jre-headless \
&& curl -sS ${MAVEN_CENTRAL_REPO_URL}/org/eclipse/jetty/jetty-runner/9.4.46.v20220331/jetty-runner-9.4.46.v20220331.jar --output jetty-runner.jar \
&& curl -sS ${MAVEN_CENTRAL_REPO_URL}/org/eclipse/jetty/jetty-jmx/9.4.46.v20220331/jetty-jmx-9.4.46.v20220331.jar --output jetty-jmx.jar \
&& curl -sS ${MAVEN_CENTRAL_REPO_URL}/org/eclipse/jetty/jetty-util/9.4.46.v20220331/jetty-util-9.4.46.v20220331.jar --output jetty-util.jar \
&& wget --no-verbose http://maven.cqcztech.cn/repository/maven-public/io/opentelemetry/javaagent/opentelemetry-javaagent/1.24.0/opentelemetry-javaagent-1.24.0.jar -O opentelemetry-javaagent.jar \
&& wget --no-verbose ${MAVEN_CENTRAL_REPO_URL}/io/prometheus/jmx/jmx_prometheus_javaagent/${JMX_VERSION}/jmx_prometheus_javaagent-${JMX_VERSION}.jar -O jmx_prometheus_javaagent.jar \
&& cp /usr/lib/jvm/java-11-openjdk/jre/lib/security/cacerts /tmp/kafka.client.truststore.jks
COPY --from=binary /go/bin/dockerize /usr/local/bin
ENV LD_LIBRARY_PATH="/lib:/lib64"
FROM base as prod-install
COPY datahub-upgrade.jar /datahub/datahub-upgrade/bin/
COPY metadata-models/src/main/resources/entity-registry.yml /datahub/datahub-gms/resources/entity-registry.yml
FROM base as dev-install
# Dummy stage for development. Assumes code is built on your machine and mounted to this image.
# See this excellent thread https://github.com/docker/cli/issues/1134
FROM ${APP_ENV}-install as final
RUN addgroup -S datahub && adduser -S datahub -G datahub
USER datahub
ENTRYPOINT ["java", "-jar", "/datahub/datahub-upgrade/bin/datahub-upgrade.jar"]
标签:--,jar,jetty,开源,Build,https,datahub,DockerFIle,docker
From: https://www.cnblogs.com/gtnotgod/p/17903661.html