REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu 19.04 9b17fc7d6848 5 days ago 75.4MB alpine 3.9 055936d39205 10 days ago 5.53MB busybox latest 64f5d945efcc 11 days ago 1.2MB centos 7.6.1810 f1cb7c7d58b7 2 months ago 202MB
制作基础系统镜像alpine、centos、ubuntu 注意: 所有基础镜像及部署软件都要指定好具体版本,禁用last tag
下载alpine基础镜像
1 2 3 4 5 6 7 8 9
[root@VM_8_24_centos ~]# docker pull alpine:v3.9 Error response from daemon: manifest for alpine:v3.9 not found [root@VM_8_24_centos ~]# docker pull alpine:3.9 3.9: Pulling from library/alpine Digest: sha256:769fddc7cc2f0a1c35abb2f91432e8beecf83916c421420e6a6da9f8975464b6 Status: Downloaded newer image for alpine:3.9 [root@VM_8_24_centos ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE alpine 3.9 055936d39205 10 days ago 5.53MB
登陆私有镜像库
1 2 3 4 5 6 7 8
[root@VM_8_24_centos ~]# docker login core-harbor.minminmsn.com Username: admin Password: WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
打标签上传到私有镜像库
1 2 3 4 5
[root@VM_8_24_centos ~]# docker tag library/alpine:3.9 core-harbor.minminmsn.com/public/alpine:3.9 [root@VM_8_24_centos ~]# docker push core-harbor.minminmsn.com/public/alpine:3.9 The push refers to repository [core-harbor.minminmsn.com/public/alpine] f1b5933fe4b5: Pushed 3.9: digest: sha256:bf1684a6e3676389ec861c602e97f27b03f14178e5bc3f70dce198f9f160cce9 size: 528
同样方法制作centos、ubuntu系统基础镜像
1 2 3 4 5 6 7 8
[root@VM_8_24_centos ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE core-harbor.minminmsn.com/public/ubuntu 19.04 9b17fc7d6848 5 days ago 75.4MB ubuntu 19.04 9b17fc7d6848 5 days ago 75.4MB core-harbor.minminmsn.com/public/alpine 3.9 055936d39205 10 days ago 5.53MB alpine 3.9 055936d39205 10 days ago 5.53MB core-harbor.minminmsn.com/public/centos 7.6.1810 f1cb7c7d58b7 2 months ago 202MB centos 7.6.1810 f1cb7c7d58b7 2 months ago 202MB
在centos基础镜像上制作jre镜像
下载jre包
1 2 3
[work@VM_8_24_centos jre-centos]# wget https://github.com/frekele/oracle-java/releases/download/8u212-b10/jre-8u212-linux-x64.tar.gz [work@VM_8_24_centos jre-centos]# ls jre-8u212-linux-x64.tar.gz
编辑Dockerfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
[work@VM_8_24_centos jre-centos]# cat Dockerfile # 基础镜像 FROM core-harbor.minminmsn.com/public/centos:7.6.1810
[root@VM_8_24_centos jre-centos]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE core-harbor.minminmsn.com/public/jre-centos 1.8.0_212 f27d47159f1e 17 seconds ago 441MB
上传镜像到私有镜像库
1 2 3 4 5
[root@VM_8_24_centos jre-centos]# docker push core-harbor.minminmsn.com/public/jre-centos:1.8.0_212 The push refers to repository [core-harbor.minminmsn.com/public/jre-centos] b9049811dc7d: Pushed 89169d87dbe2: Mounted from public/jdk-centos 1.8.0_212: digest: sha256:5c909a0c33aaa13b3a3ce48fd0f60356a32c5a697d99f39f08e92f1c6ba7bd57 size: 741
运行验证jre镜像
1 2 3 4
[root@VM_8_24_centos jre-centos]# docker run core-harbor.minminmsn.com/public/jre-centos:1.8.0_212 java version "1.8.0_212" Java(TM) SE Runtime Environment (build 1.8.0_212-b10) Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode)