MCSManager使用Ubuntu 22.04预装21.0.2的jdk

wuchenchina 发布于 2024-03-19 328 次阅读


最近准备搞个我的世界的服务器,但是看了下,MCSManager的Dockerfile(含有jdk的)最新只是17。

file

随后,上 hub.docker.com 看了下,jdk21貌似没有官方的镜像(不清楚)

file

随后就想着能不能看下azul的镜像,果真,有!但是吧,国内的服务器pull镜像的速度实在是有些感人

file

最后,在再三思索下,使用Ubuntu 22.04做基础搞一个,说整就整,开干!(玩的就是真实)

准备工作

安装Docker

目前常见的系统是CentOS、Ubuntu、Debian等等的,这些系统可以直接使用 get.docker.com进行安装:

file

file

安装命令:

curl -fsSL https://get.docker.com -o install-docker.sh ; chmod +x install-docker.sh ; ./install_docker.sh --mirror Aliyun

# 如果不是中国的机子,也可以不使用Aliyun的镜像源,也就是把“--mirror Aliyun”给去掉,如下:
# curl -fsSL https://get.docker.com -o install-docker.sh ; chmod +x install-docker.sh ; ./install_docker.sh

安装Docker和Docker-Compose

curl -fsSL https://get.docker.com -o install-docker.sh ; chmod 777 install-docker.sh ; ./install-docker.sh --mirror Aliyun ; systemctl enable docker ; sudo curl -L "https://mirror.ghproxy.com/https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose ; sudo chmod +x /usr/local/bin/docker-compose ; docker --version ; docker-compose --version

如果是其他的新型镜像,也可以试着使用get.docker.com,但是像OpenCloudOS这类镜像(不一定,上次测试的版本不多,而且时间比较久,不清楚有没有支持呢)也可以试试以下方法

sudo yum update
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io
# 也可以sudo yum install -y docker* containerd.io(没测试过)
# get.docker.com是:
# yum install -y -q docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-ce-rootless-extras docker-buildx-plugin

其实国内也可以用其他的,像阿里云和北京大学
北京大学参考:北京大学开源镜像站

sudo wget http://mirrors.pku.edu.cn/repoconfig/docker-ce/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo ; yum makecache

北京大学理论可以这样的,因为OpenCloudOS实际也可以视为CentOS的衍生版(不一定,个人理解,有误请联系纠正)
阿里云参考:阿里云 Docker

sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo

检查Docker是否安装成功:

docker --version

# docker-compose是否安装成功:
# docker-compose --version

file
(折腾成功示例)

pull Ubuntu 22.04的镜像

docker pull ubuntu:22.04

如果是国内,可以考虑使用dockerproxy.com或者阿里云的Docker镜像加速

DockerProxy:

docker pull dockerproxy.com/library/ubuntu:22.04
docker tag dockerproxy.com/library/ubuntu:22.04 ubuntu:22.04
docker rmi dockerproxy.com/library/ubuntu:22.04

(dockerproxy也可以考虑在后面Dockerfile直接使用dockerproxy.com/library/ubuntu:22.04,没测试过)

下载Azul或其他jdk包

我是用的是azul的,下载地址:Download

file

我是下载的.deb格式的,嘿嘿

file

然后上传到你认为OK的支持直链的网盘(或者其他办法也行,这个办法我觉得最便捷)

我已经上传了,网盘直链由万物云碟提供支持

下载链接:

https://wp.007irs.com/f/qAe4ZH0/zulu21.32.17-ca-jdk21.0.2-linux_amd64.deb

查看Ubuntu缺什么?

我们搞一个ubuntu的镜像看看:

docker run -it ubuntu:22.04

file

然后,我们试着搞一下官方镜像有的一些东西:

file

注意:mcsmanager的ubuntu镜像是18.04,请注意甄别,部分内容可能落后(不一定,我不知道)

我们的:

FROM ubuntu:22.04
ENV TZ=Asia/Shanghai
RUN sed -ri.bak -e 's/\/\/.*?(archive.ubuntu.com|mirrors.*?)\/ubuntu/\/\/mirrors.aliyun.com\/ubuntu/g' -e '/security.ubuntu.com\/ubuntu/d' /etc/apt/sources.list
RUN apt update 
RUN apt -y install libcurl4 && DEBIAN_FRONTEND="noninteractive" apt -y install tzdata
RUN apt-get install default-jre libasound2 libx11-6 libxau6 libxcb1 libxdmcp6 libxext6 libxi6 libxrender1 libxtst6 libfontconfig1 wget -y
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN mkdir -p /workspace
WORKDIR /workspace

将RUN的内容执行以下(注意甄别,有些不必要)

root@dc96711ed7fb:/# sed -ri.bak -e 's/\/\/.*?(archive.ubuntu.com|mirrors.*?)\/ubuntu/\/\/mirrors.pku.edu.cn\/ubuntu/g' -e '/security.ubuntu.com\/ubuntu/d' /etc/apt/sources.list
root@dc96711ed7fb:/# apt-get update
Get:1 http://mirrors.pku.edu.cn/ubuntu jammy InRelease [270 kB]
Get:2 http://mirrors.pku.edu.cn/ubuntu jammy-updates InRelease [119 kB]
Get:3 http://mirrors.pku.edu.cn/ubuntu jammy-backports InRelease [109 kB]
Get:4 http://mirrors.pku.edu.cn/ubuntu jammy/universe amd64 Packages [17.5 MB]
Get:5 http://mirrors.pku.edu.cn/ubuntu jammy/multiverse amd64 Packages [266 kB]
Get:6 http://mirrors.pku.edu.cn/ubuntu jammy/main amd64 Packages [1792 kB]
Get:7 http://mirrors.pku.edu.cn/ubuntu jammy/restricted amd64 Packages [164 kB]
Get:8 http://mirrors.pku.edu.cn/ubuntu jammy-updates/main amd64 Packages [1883 kB]
Get:9 http://mirrors.pku.edu.cn/ubuntu jammy-updates/universe amd64 Packages [1354 kB]
Get:10 http://mirrors.pku.edu.cn/ubuntu jammy-updates/multiverse amd64 Packages [50.4 kB]
Get:11 http://mirrors.pku.edu.cn/ubuntu jammy-updates/restricted amd64 Packages [2056 kB]
Get:12 http://mirrors.pku.edu.cn/ubuntu jammy-backports/universe amd64 Packages [33.3 kB]
Get:13 http://mirrors.pku.edu.cn/ubuntu jammy-backports/main amd64 Packages [80.9 kB]
Fetched 25.6 MB in 4s (6091 kB/s)                            
Reading package lists... Done
root@dc96711ed7fb:/# apt -y install libcurl4 && DEBIAN_FRONTEND="noninteractive" apt -y install tzdata
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  ca-certificates libbrotli1 libldap-2.5-0 libldap-common libnghttp2-14 libpsl5 librtmp1
  libsasl2-2 libsasl2-modules libsasl2-modules-db libssh-4 openssl publicsuffix
Suggested packages:
  libsasl2-modules-gssapi-mit | libsasl2-modules-gssapi-heimdal libsasl2-modules-ldap
  libsasl2-modules-otp libsasl2-modules-sql
The following NEW packages will be installed:
  ca-certificates libbrotli1 libcurl4 libldap-2.5-0 libldap-common libnghttp2-14 libpsl5
  librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libssh-4 openssl publicsuffix
0 upgraded, 14 newly installed, 0 to remove and 2 not upgraded.
Need to get 2797 kB of archives.
After this operation, 6670 kB of additional disk space will be used.
Get:1 http://mirrors.pku.edu.cn/ubuntu jammy-updates/main amd64 openssl amd64 3.0.2-0ubuntu1.15 [1186 kB]
Get:2 http://mirrors.pku.edu.cn/ubuntu jammy-updates/main amd64 ca-certificates all 20230311ubuntu0.22.04.1 [155 kB]
Get:3 http://mirrors.pku.edu.cn/ubuntu jammy-updates/main amd64 libnghttp2-14 amd64 1.43.0-1ubuntu0.1 [76.7 kB]
Get:4 http://mirrors.pku.edu.cn/ubuntu jammy/main amd64 libpsl5 amd64 0.21.0-1.2build2 [58.4 kB]
Get:5 http://mirrors.pku.edu.cn/ubuntu jammy/main amd64 publicsuffix all 20211207.1025-1 [129 kB]
Get:6 http://mirrors.pku.edu.cn/ubuntu jammy/main amd64 libbrotli1 amd64 1.0.9-2build6 [315 kB]
Get:7 http://mirrors.pku.edu.cn/ubuntu jammy-updates/main amd64 libsasl2-modules-db amd64 2.1.27+dfsg2-3ubuntu1.2 [20.5 kB]
Get:8 http://mirrors.pku.edu.cn/ubuntu jammy-updates/main amd64 libsasl2-2 amd64 2.1.27+dfsg2-3ubuntu1.2 [53.8 kB]
Get:9 http://mirrors.pku.edu.cn/ubuntu jammy-updates/main amd64 libldap-2.5-0 amd64 2.5.17+dfsg-0ubuntu0.22.04.1 [183 kB]
Get:10 http://mirrors.pku.edu.cn/ubuntu jammy/main amd64 librtmp1 amd64 2.4+20151223.gitfa8646d.1-2build4 [58.2 kB]
Get:11 http://mirrors.pku.edu.cn/ubuntu jammy-updates/main amd64 libssh-4 amd64 0.9.6-2ubuntu0.22.04.3 [186 kB]
Get:12 http://mirrors.pku.edu.cn/ubuntu jammy-updates/main amd64 libcurl4 amd64 7.81.0-1ubuntu1.15 [289 kB]
Get:13 http://mirrors.pku.edu.cn/ubuntu jammy-updates/main amd64 libldap-common all 2.5.17+dfsg-0ubuntu0.22.04.1 [15.8 kB]
Get:14 http://mirrors.pku.edu.cn/ubuntu jammy-updates/main amd64 libsasl2-modules amd64 2.1.27+dfsg2-3ubuntu1.2 [68.8 kB]
Fetched 2797 kB in 1s (3011 kB/s)            
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package openssl.
(Reading database ... 4393 files and directories currently installed.)
Preparing to unpack .../00-openssl_3.0.2-0ubuntu1.15_amd64.deb ...
Unpacking openssl (3.0.2-0ubuntu1.15) ...
Selecting previously unselected package ca-certificates.
Preparing to unpack .../01-ca-certificates_20230311ubuntu0.22.04.1_all.deb ...
Unpacking ca-certificates (20230311ubuntu0.22.04.1) ...
Selecting previously unselected package libnghttp2-14:amd64.
Preparing to unpack .../02-libnghttp2-14_1.43.0-1ubuntu0.1_amd64.deb ...
Unpacking libnghttp2-14:amd64 (1.43.0-1ubuntu0.1) ...
Selecting previously unselected package libpsl5:amd64.
Preparing to unpack .../03-libpsl5_0.21.0-1.2build2_amd64.deb ...
Unpacking libpsl5:amd64 (0.21.0-1.2build2) ...
Selecting previously unselected package publicsuffix.
Preparing to unpack .../04-publicsuffix_20211207.1025-1_all.deb ...
Unpacking publicsuffix (20211207.1025-1) ...
Selecting previously unselected package libbrotli1:amd64.
Preparing to unpack .../05-libbrotli1_1.0.9-2build6_amd64.deb ...
Unpacking libbrotli1:amd64 (1.0.9-2build6) ...
Selecting previously unselected package libsasl2-modules-db:amd64.
Preparing to unpack .../06-libsasl2-modules-db_2.1.27+dfsg2-3ubuntu1.2_amd64.deb ...
Unpacking libsasl2-modules-db:amd64 (2.1.27+dfsg2-3ubuntu1.2) ...
Selecting previously unselected package libsasl2-2:amd64.
Preparing to unpack .../07-libsasl2-2_2.1.27+dfsg2-3ubuntu1.2_amd64.deb ...
Unpacking libsasl2-2:amd64 (2.1.27+dfsg2-3ubuntu1.2) ...
Selecting previously unselected package libldap-2.5-0:amd64.
Preparing to unpack .../08-libldap-2.5-0_2.5.17+dfsg-0ubuntu0.22.04.1_amd64.deb ...
Unpacking libldap-2.5-0:amd64 (2.5.17+dfsg-0ubuntu0.22.04.1) ...
Selecting previously unselected package librtmp1:amd64.
Preparing to unpack .../09-librtmp1_2.4+20151223.gitfa8646d.1-2build4_amd64.deb ...
Unpacking librtmp1:amd64 (2.4+20151223.gitfa8646d.1-2build4) ...
Selecting previously unselected package libssh-4:amd64.
Preparing to unpack .../10-libssh-4_0.9.6-2ubuntu0.22.04.3_amd64.deb ...
Unpacking libssh-4:amd64 (0.9.6-2ubuntu0.22.04.3) ...
Selecting previously unselected package libcurl4:amd64.
Preparing to unpack .../11-libcurl4_7.81.0-1ubuntu1.15_amd64.deb ...
Unpacking libcurl4:amd64 (7.81.0-1ubuntu1.15) ...
Selecting previously unselected package libldap-common.
Preparing to unpack .../12-libldap-common_2.5.17+dfsg-0ubuntu0.22.04.1_all.deb ...
Unpacking libldap-common (2.5.17+dfsg-0ubuntu0.22.04.1) ...
Selecting previously unselected package libsasl2-modules:amd64.
Preparing to unpack .../13-libsasl2-modules_2.1.27+dfsg2-3ubuntu1.2_amd64.deb ...
Unpacking libsasl2-modules:amd64 (2.1.27+dfsg2-3ubuntu1.2) ...
Setting up libpsl5:amd64 (0.21.0-1.2build2) ...
Setting up libbrotli1:amd64 (1.0.9-2build6) ...
Setting up libsasl2-modules:amd64 (2.1.27+dfsg2-3ubuntu1.2) ...
Setting up libnghttp2-14:amd64 (1.43.0-1ubuntu0.1) ...
Setting up libldap-common (2.5.17+dfsg-0ubuntu0.22.04.1) ...
Setting up libsasl2-modules-db:amd64 (2.1.27+dfsg2-3ubuntu1.2) ...
Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d.1-2build4) ...
Setting up libsasl2-2:amd64 (2.1.27+dfsg2-3ubuntu1.2) ...
Setting up libssh-4:amd64 (0.9.6-2ubuntu0.22.04.3) ...
Setting up openssl (3.0.2-0ubuntu1.15) ...
Setting up publicsuffix (20211207.1025-1) ...
Setting up libldap-2.5-0:amd64 (2.5.17+dfsg-0ubuntu0.22.04.1) ...
Setting up ca-certificates (20230311ubuntu0.22.04.1) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.34.0 /usr/local/share/perl/5.34.0 /usr/lib/x86_64-linux-gnu/perl5/5.34 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.34 /usr/share/perl/5.34 /usr/local/lib/site_perl) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Updating certificates in /etc/ssl/certs...
137 added, 0 removed; done.
Setting up libcurl4:amd64 (7.81.0-1ubuntu1.15) ...
Processing triggers for libc-bin (2.35-0ubuntu3.6) ...
Processing triggers for ca-certificates (20230311ubuntu0.22.04.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  tzdata
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 348 kB of archives.
After this operation, 3994 kB of additional disk space will be used.
Get:1 http://mirrors.pku.edu.cn/ubuntu jammy-updates/main amd64 tzdata all 2024a-0ubuntu0.22.04 [348 kB]
Fetched 348 kB in 0s (1647 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package tzdata.
(Reading database ... 4970 files and directories currently installed.)
Preparing to unpack .../tzdata_2024a-0ubuntu0.22.04_all.deb ...
Unpacking tzdata (2024a-0ubuntu0.22.04) ...
Setting up tzdata (2024a-0ubuntu0.22.04) ...

Current default time zone: 'Etc/UTC'
Local time is now:      Tue Mar 19 14:37:25 UTC 2024.
Universal Time is now:  Tue Mar 19 14:37:25 UTC 2024.
Run 'dpkg-reconfigure tzdata' if you wish to change it.

大概得这样,就初步得到了mcsmanager同款预装镜像(我此处使用的是北京大学的镜像,到时候咱们到底用阿里云还是北大还是其他镜像站主要的还是看自己服务器的速度,效率第一对不对哈哈),接下来,我们来测试安装jdk

apt-get install -y wget
wget https://wp.007irs.com/f/qAe4ZH0/zulu21.32.17-ca-jdk21.0.2-linux_amd64.deb
dpkg -i zulu21.32.17-ca-jdk21.0.2-linux_amd64.deb

接着,我们得到这些:

root@dc96711ed7fb:/# apt-get install -y wget
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  wget
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 367 kB of archives.
After this operation, 1008 kB of additional disk space will be used.
Get:1 http://mirrors.pku.edu.cn/ubuntu jammy/main amd64 wget amd64 1.21.2-2ubuntu1 [367 kB]
Fetched 367 kB in 0s (1777 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package wget.
(Reading database ... 6850 files and directories currently installed.)
Preparing to unpack .../wget_1.21.2-2ubuntu1_amd64.deb ...
Unpacking wget (1.21.2-2ubuntu1) ...
Setting up wget (1.21.2-2ubuntu1) ...
root@dc96711ed7fb:/# wget https://wp.007irs.com/f/qAe4ZH0/zulu21.32.17-ca-jdk21.0.2-linux_amd64.deb
--2024-03-19 14:41:37--  https://wp.007irs.com/f/qAe4ZH0/zulu21.32.17-ca-jdk21.0.2-linux_amd64.deb
Resolving wp.007irs.com (wp.007irs.com)... 123.99.201.83, 123.99.201.99, 123.99.201.104
Connecting to wp.007irs.com (wp.007irs.com)|123.99.201.83|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://download.007irs.com/personal/cenlin_cenlin_onmicrosoft_com/_layouts/15/download.aspx?UniqueId=41e1812b-49fb-4eea-b646-f75e5ceb4a46&Translate=false&tempauth=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAvY2VubGluLW15LnNoYXJlcG9pbnQuY29tQGM5NzRjYjU2LTFiZTMtNDNlMi1hNmMyLTVlMzM2Y2VlNmU2YiIsImlzcyI6IjAwMDAwMDAzLTAwMDAtMGZmMS1jZTAwLTAwMDAwMDAwMDAwMCIsIm5iZiI6IjE3MTA4NTkyOTgiLCJleHAiOiIxNzEwODYyODk4IiwiZW5kcG9pbnR1cmwiOiJWSnJZV0hVZk5neUJ4QmRvZENPUGxhMEJZT2lIS2xYQWpFYVVhZGEwOGVFPSIsImVuZHBvaW50dXJsTGVuZ3RoIjoiMTU5IiwiaXNsb29wYmFjayI6IlRydWUiLCJjaWQiOiJ1SUZTVi9XeFprYXl6M3BWWFAyOStRPT0iLCJ2ZXIiOiJoYXNoZWRwcm9vZnRva2VuIiwic2l0ZWlkIjoiTkdWaU1qVmlZVFl0TXpKaFl5MDBOamRsTFdFNU1HTXRZbUk0TnpNMU9EUTJNVEV5IiwiYXBwX2Rpc3BsYXluYW1lIjoib2QwMDEiLCJnaXZlbl9uYW1lIjoi5p6XIiwiZmFtaWx5X25hbWUiOiLpmYgiLCJhcHBpZCI6IjhiYTliY2ZlLTFiODMtNDMzYy04MzUxLTVlMzZhNGRiYTE1MCIsInRpZCI6ImM5NzRjYjU2LTFiZTMtNDNlMi1hNmMyLTVlMzM2Y2VlNmU2YiIsInVwbiI6ImNlbmxpbkBjZW5saW4ub25taWNyb3NvZnQuY29tIiwicHVpZCI6IjEwMDMyMDAyQTQ1RUZDRkQiLCJjYWNoZWtleSI6IjBoLmZ8bWVtYmVyc2hpcHwxMDAzMjAwMmE0NWVmY2ZkQGxpdmUuY29tIiwic2NwIjoiYWxsZmlsZXMud3JpdGUiLCJ0dCI6IjIiLCJpcGFkZHIiOiIyMC4xOTAuMTQ0LjE3MCJ9.y4QO_AcPyoRlbV9pUhoyNk28HlMtN9Rn0da-EKEJ72w&ApiVersion=2.0 [following]
--2024-03-19 14:41:38--  https://download.007irs.com/personal/cenlin_cenlin_onmicrosoft_com/_layouts/15/download.aspx?UniqueId=41e1812b-49fb-4eea-b646-f75e5ceb4a46&Translate=false&tempauth=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAvY2VubGluLW15LnNoYXJlcG9pbnQuY29tQGM5NzRjYjU2LTFiZTMtNDNlMi1hNmMyLTVlMzM2Y2VlNmU2YiIsImlzcyI6IjAwMDAwMDAzLTAwMDAtMGZmMS1jZTAwLTAwMDAwMDAwMDAwMCIsIm5iZiI6IjE3MTA4NTkyOTgiLCJleHAiOiIxNzEwODYyODk4IiwiZW5kcG9pbnR1cmwiOiJWSnJZV0hVZk5neUJ4QmRvZENPUGxhMEJZT2lIS2xYQWpFYVVhZGEwOGVFPSIsImVuZHBvaW50dXJsTGVuZ3RoIjoiMTU5IiwiaXNsb29wYmFjayI6IlRydWUiLCJjaWQiOiJ1SUZTVi9XeFprYXl6M3BWWFAyOStRPT0iLCJ2ZXIiOiJoYXNoZWRwcm9vZnRva2VuIiwic2l0ZWlkIjoiTkdWaU1qVmlZVFl0TXpKaFl5MDBOamRsTFdFNU1HTXRZbUk0TnpNMU9EUTJNVEV5IiwiYXBwX2Rpc3BsYXluYW1lIjoib2QwMDEiLCJnaXZlbl9uYW1lIjoi5p6XIiwiZmFtaWx5X25hbWUiOiLpmYgiLCJhcHBpZCI6IjhiYTliY2ZlLTFiODMtNDMzYy04MzUxLTVlMzZhNGRiYTE1MCIsInRpZCI6ImM5NzRjYjU2LTFiZTMtNDNlMi1hNmMyLTVlMzM2Y2VlNmU2YiIsInVwbiI6ImNlbmxpbkBjZW5saW4ub25taWNyb3NvZnQuY29tIiwicHVpZCI6IjEwMDMyMDAyQTQ1RUZDRkQiLCJjYWNoZWtleSI6IjBoLmZ8bWVtYmVyc2hpcHwxMDAzMjAwMmE0NWVmY2ZkQGxpdmUuY29tIiwic2NwIjoiYWxsZmlsZXMud3JpdGUiLCJ0dCI6IjIiLCJpcGFkZHIiOiIyMC4xOTAuMTQ0LjE3MCJ9.y4QO_AcPyoRlbV9pUhoyNk28HlMtN9Rn0da-EKEJ72w&ApiVersion=2.0
Resolving download.007irs.com (download.007irs.com)... 104.17.110.201, 104.17.249.148, 104.19.205.60
Connecting to download.007irs.com (download.007irs.com)|104.17.110.201|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 180525418 (172M) [application/octet-stream]
Saving to: 'zulu21.32.17-ca-jdk21.0.2-linux_amd64.deb'

zulu21.32.17-ca-jdk21. 100%[==========================>] 172.16M  4.02MB/s    in 52s     

2024-03-19 14:42:32 (3.33 MB/s) - 'zulu21.32.17-ca-jdk21.0.2-linux_amd64.deb' saved [180525418/180525418]

root@dc96711ed7fb:/# dpkg -i zulu21.32.17-ca-jdk21.0.2-linux_amd64.deb
Selecting previously unselected package zulu-21.
(Reading database ... 6861 files and directories currently installed.)
Preparing to unpack zulu21.32.17-ca-jdk21.0.2-linux_amd64.deb ...
Unpacking zulu-21 (21.32+17-1) ...
dpkg: dependency problems prevent configuration of zulu-21:
 zulu-21 depends on java-common; however:
  Package java-common is not installed.
 zulu-21 depends on libasound2; however:
  Package libasound2 is not installed.
 zulu-21 depends on libx11-6; however:
  Package libx11-6 is not installed.
 zulu-21 depends on libxau6; however:
  Package libxau6 is not installed.
 zulu-21 depends on libxcb1; however:
  Package libxcb1 is not installed.
 zulu-21 depends on libxdmcp6; however:
  Package libxdmcp6 is not installed.
 zulu-21 depends on libxext6; however:
  Package libxext6 is not installed.
 zulu-21 depends on libxi6; however:
  Package libxi6 is not installed.
 zulu-21 depends on libxrender1; however:
  Package libxrender1 is not installed.
 zulu-21 depends on libxtst6; however:
  Package libxtst6 is not installed.
 zulu-21 depends on libfontconfig1; however:
  Package libfontconfig1 is not installed.

dpkg: error processing package zulu-21 (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 zulu-21
root@dc96711ed7fb:/#

file

这一段就是我们目前缺失的一些东西,综合后,我们得出这个命令,用于安装所有的依赖的包:

apt-get install default-jre libasound2 libx11-6 libxau6 libxcb1 libxdmcp6 libxext6 libxi6 libxrender1 libxtst6 libfontconfig1 -y

好的,这时候就可以退出这个容器了(记得将容器删除,这个容器对我们没用了)

根据实际内容编写Dockerfile

就地写一个Dockerfile:

注意:存放有该Dockerfile的尽可能的不要有其他的Dockerfile,避免冲突,最佳做法:mkdir ~/mcsm-ubuntu2204 && cd ~/mcsm-ubuntu2204

vim Dockerfile

如果没有vim,可以考虑yum install -y vimapt-get install -y vim,也可以使用vi:vi Dockerfile

Dockerfile:

FROM ubuntu:22.04
ENV TZ=Asia/Shanghai
RUN sed -ri.bak -e 's/\/\/.*?(archive.ubuntu.com|mirrors.*?)\/ubuntu/\/\/mirrors.aliyun.com\/ubuntu/g' -e '/security.ubuntu.com\/ubuntu/d' /etc/apt/sources.list
RUN apt update 
RUN apt -y install libcurl4 && DEBIAN_FRONTEND="noninteractive" apt -y install tzdata
RUN apt-get install default-jre libasound2 libx11-6 libxau6 libxcb1 libxdmcp6 libxext6 libxi6 libxrender1 libxtst6 libfontconfig1 wget -y
RUN wget https://wp.007irs.com/f/qAe4ZH0/zulu21.32.17-ca-jdk21.0.2-linux_amd64.deb
RUN dpkg -i zulu21.32.17-ca-jdk21.0.2-linux_amd64.deb
RUN rm -rf zulu21.32.17-ca-jdk21.0.2-linux_amd64.deb
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN mkdir -p /workspace
WORKDIR /workspace

Docker IMAGES Build

最后,我们在含有该Dockerfile的目录进行build:

docker build -t mcsm-ubuntu:22.04_zulu21 .

最后,大功告成!

file