Introduction to Alpine Linux
1.Alpine Linux is a lightweight Linux distribution. It is different from the usual Linux distribution (centos, Ubuntu), Alpine uses musl libc and BusyBox reduces system size and runtime resource consumption. 2.Alpine Linux provides its own package management tool: apk (note: apt-get in ubuntu), and we can query package information through https://pkgs.alpinelinux.org/packages 3. The Alpine Docker image inherits these advantages of the Alpine Linux distribution and is very small compared to other Linux Docker images Compare common, uncompressed base images (see the current: latest tag): Alpine - 4.8MB centos - 124.8 MB Debian - 125.1MB Centos - 196MB 4. Alpine Linux version 3.10.0 is recommended, which is also the first version in the v3.10 stable series alpine:3.10
Alpine Makes jdk Mirror
Now that you're using Alpine, it's natural to download the mirror first
docker pull alpine:3.10
Delete the previous Dockerfile and reproduce it first.
Create and edit dockerfile
touch Dockerfile
vi Dockerfile
The contents are as follows:
#1. Specify the base image and must be the first instruction #FROM alpine:latest FROM alpine:3.10 #2. Indicate the author of the mirror and its e-mail MAINTAINER zzz "zzz@qq.com" #3. When you build the image, specify the working directory for the image, and subsequent commands are based on this working directory. If it does not exist, the directory will be created WORKDIR /pyc_docker/jdk #4. Copy some installation packages into the mirror, Syntax: ADD/COPY <src>... <dest> ## Difference between ADD and COPY: ADD copies and decompresses, COPY copies only ADD jdk-8u221-linux-x64.tar.gz /pyc_docker/jdk/ ## glibc installation packages if downloading from the network is too slow, download and copy to the mirror ahead of time COPY glibc-2.29-r0.apk /pyc_docker/jdk/ COPY glibc-bin-2.29-r0.apk /pyc_docker/jdk/ COPY glibc-i18n-2.29-r0.apk /pyc_docker/jdk/ #5. Update Alpine's software source is Aliyun, because pulling from the default source is too slow RUN echo http://mirrors.aliyun.com/alpine/v3.10/main/ > /etc/apk/repositories && \ echo http://mirrors.aliyun.com/alpine/v3.10/community/ >> /etc/apk/repositories RUN apk update && apk upgrade #6. Run the specified command ## Alpine linux does not install too many common software in order to simplify itself. The apk is similar to ubuntu's apt-get. ## Used to install some common software Vs with the following syntax:apk add bash wget curl git make vim docker ## WGet is a ftp/http transport tool under linux. Failure to install will result in an error'/bin/sh: wget: not found'. Install less WGet for online examples ## ca-certificates Certificate Service, a pre-dependency for installing glibc RUN apk --no-cache add ca-certificates wget \ && wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \ && apk add glibc-2.29-r0.apk glibc-bin-2.29-r0.apk glibc-i18n-2.29-r0.apk \ && rm -rf /var/cache/apk/* glibc-2.29-r0.apk glibc-bin-2.29-r0.apk glibc-i18n-2.29-r0.apk #7. Configuring environment variables ENV JAVA_HOME=/pyc_docker/jdk/jdk1.8.0_221 ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar ENV PATH=$JAVA_HOME/bin:$PATH #Commands to execute when the container starts #CMD ["java","-version"]
Execute dockerfile to create a mirror
docker build -t jdk8:v2.0 .
Test if you can use it
Alpine Makes a jre Mirror
Upload File First Unzip
tar -zxvf jre-8u221-linux-x64.tar.gz
Delete Compressed Packet
View jre file size
du -sh jre1.8.0_221
Enter the Execute Slim Command
#Delete Text File rm -rf COPYRIGHT LICENSE README release THIRDPARTYLICENSEREADME-JAVAFX.txtTHIRDPARTYLICENSEREADME.txt Welcome.html \ #Delete other useless files rm -rf lib/plugin.jar \ lib/ext/jfxrt.jar \ bin/javaws \ lib/javaws.jar \ lib/desktop \ plugin \ lib/deploy* \ lib/*javafx* \ lib/*jfx* \ lib/amd64/libdecora_sse.so \ lib/amd64/libprism_*.so \ lib/amd64/libfxplugins.so \ lib/amd64/libglass.so \ lib/amd64/libgstreamer-lite.so \ lib/amd64/libjavafx*.so \ lib/amd64/libjfx*.so
View again
Retype compressed packages and delete folders and Dockerfile s
jre1.8.0_221.tar.gz jre1.8.0_221
Enter:
#1. Specify the base image and must be the first instruction #FROM alpine:latest FROM alpine:3.10 #2. Indicate the author of the mirror and its e-mail MAINTAINER xyz "xyz@qq.com" #3. When you build the image, specify the working directory for the image, and subsequent commands are based on this working directory. If it does not exist, the directory will be created WORKDIR /pyc_docker/jdk #4. Copy some installation packages into the mirror, Syntax: ADD/COPY <src>... <dest> ## Difference between ADD and COPY: ADD copies and decompresses, COPY copies only ## Note ~~Uploaded slim jre ADD jre1.8.0_221.tar.gz /pyc_docker/jdk/ ## glibc installation packages if downloading from the network is too slow, download and copy to the mirror ahead of time COPY glibc-2.29-r0.apk /pyc_docker/jdk/ COPY glibc-bin-2.29-r0.apk /pyc_docker/jdk/ COPY glibc-i18n-2.29-r0.apk /pyc_docker/jdk/ #5. Update Alpine's software source is Aliyun, because pulling from the default source is too slow RUN echo http://mirrors.aliyun.com/alpine/v3.10/main/ > /etc/apk/repositories && \ echo http://mirrors.aliyun.com/alpine/v3.10/community/ >> /etc/apk/repositories RUN apk update && apk upgrade #6. Run the specified command ## Alpine linux does not install too many common software in order to simplify itself. The apk is similar to ubuntu's apt-get. ## Used to install some common software Vs with the following syntax:apk add bash wget curl git make vim docker ## WGet is a ftp/http transport tool under linux. Failure to install will result in an error'/bin/sh: wget: not found'. Install less WGet for online examples ## ca-certificates Certificate Service, a pre-dependency for installing glibc RUN apk --no-cache add ca-certificates wget \ && wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \ && apk add glibc-2.29-r0.apk glibc-bin-2.29-r0.apk glibc-i18n-2.29-r0.apk \ && rm -rf /var/cache/apk/* glibc-2.29-r0.apk glibc-bin-2.29-r0.apk glibc-i18n-2.29-r0.apk #7. Configuring environment variables ## Notice ~~No jdk, just point to jre ENV JAVA_HOME=/pyc_docker/jdk/jre1.8.0_221 ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar ENV PATH=$JAVA_HOME/bin:$PATH #Commands to execute when the container starts #CMD ["java","-version"]
Execute dockerfile to create a mirror
docker build -t jdk8:v3.0 .
Test Availability
docker run -it --name myjdk3 53d5b8acec40
Docker image uploaded to Aliyun
Log in to Ali Cloud: https://dev.aliyun.com Note: Search for "Container Mirror Service"
Create your own mirror repository: name it first
Log in to GitHub to create your own private library
Login to Ali Cloud Docker Registry (tutorials on installing Ali Cloud Container Mirror Service...)
docker login --username=sirm39 registry.cn-hangzhou.aliyuncs.com
Add tag s for local mirrors
docker tag 53d5b8acec40 registry.cn-hangzhou.aliyuncs.com/pyc_first/apline_jre:v1.0
Push Mirror
docker push registry.cn-hangzhou.aliyuncs.com/pyc_first/apline_jre:v1.0
Upload successful...
Test if the uploaded can be used
Pull Ali Cloud Mirror to Local Area
docker pull registry.cn-hangzhou.aliyuncs.com/pyc_first/apline_jre:v1.0
Wait for successful test