[root@localhost opt]# docker build -t rockey8_jdk17:1.0.0 .Sending build context to Docker daemon 566.8MBStep 1/11 : FROM rockylinux:8.98.9: Pulling from library/rockylinux9088cdb84e39: Pull complete Digest: sha256:9794037624aaa6212aeada1d28861ef5e0a935adaf93e4ef79837119f2a2d04cStatus: Downloaded newer image for rockylinux:8.9 ---> c79048e50f5fStep 2/11 : MAINTAINER lzj2023@foxmail.com ---> Running in 9c40b7e878e1Removing intermediate container 9c40b7e878e1 ---> e58d03a7ebaeStep 3/11 : ENV MYPATH /opt ---> Running in d8448a9b4329Removing intermediate container d8448a9b4329 ---> da5da26abbe3Step 4/11 : WORKDIR $MYPATH ---> Running in ddf20f025c3fRemoving intermediate container ddf20f025c3f ---> 2fe907e79d95Step 5/11 : RUN yum -y install vim ---> Running in f88378120cc1Rocky Linux 8 - AppStream 3.4 MB/s | 15 MB 00:04 Rocky Linux 8 - BaseOS 2.5 MB/s | 9.4 MB 00:03 Rocky Linux 8 - Extras 5.1 kB/s | 14 kB 00:02 Dependencies resolved.================================================================================ Package Arch Version Repository Size================================================================================Installing: vim-enhanced x86_64 2:8.0.1763-19.el8_6.4 appstream 1.4 MInstalling dependencies: gpm-libs x86_64 1.20.7-17.el8 appstream 38 k vim-common x86_64 2:8.0.1763-19.el8_6.4 appstream 6.3 M vim-filesystem noarch 2:8.0.1763-19.el8_6.4 appstream 49 k which x86_64 2.21-20.el8 baseos 49 kTransaction Summary================================================================================Install 5 PackagesTotal download size: 7.8 MInstalled size: 30 MDownloading Packages:[MIRROR] gpm-libs-1.20.7-17.el8.x86_64.rpm: Curl error (52): Server returned nothing (no headers, no data) for http://au.mirrors.cicku.me/rocky/8.10/AppStream/x86_64/os/Packages/g/gpm-libs-1.20.7-17.el8.x86_64.rpm [Empty reply from server][MIRROR] vim-common-8.0.1763-19.el8_6.4.x86_64.rpm: Curl error (52): Server returned nothing (no headers, no data) for http://au.mirrors.cicku.me/rocky/8.10/AppStream/x86_64/os/Packages/v/vim-common-8.0.1763-19.el8_6.4.x86_64.rpm [Empty reply from server][MIRROR] vim-enhanced-8.0.1763-19.el8_6.4.x86_64.rpm: Curl error (52): Server returned nothing (no headers, no data) for http://au.mirrors.cicku.me/rocky/8.10/AppStream/x86_64/os/Packages/v/vim-enhanced-8.0.1763-19.el8_6.4.x86_64.rpm [Empty reply from server](1/5): gpm-libs-1.20.7-17.el8.x86_64.rpm 4.6 kB/s | 38 kB 00:08 (2/5): vim-filesystem-8.0.1763-19.el8_6.4.noarc 172 kB/s | 49 kB 00:00 (3/5): vim-common-8.0.1763-19.el8_6.4.x86_64.rp 725 kB/s | 6.3 MB 00:08 (4/5): vim-enhanced-8.0.1763-19.el8_6.4.x86_64. 144 kB/s | 1.4 MB 00:09 [MIRROR] which-2.21-20.el8.x86_64.rpm: Curl error (52): Server returned nothing (no headers, no data) for http://au.mirrors.cicku.me/rocky/8.10/BaseOS/x86_64/os/Packages/w/which-2.21-20.el8.x86_64.rpm [Empty reply from server](5/5): which-2.21-20.el8.x86_64.rpm 7.4 kB/s | 49 kB 00:06 --------------------------------------------------------------------------------Total 449 kB/s | 7.8 MB 00:17 Rocky Linux 8 - AppStream 1.6 MB/s | 1.6 kB 00:00 Importing GPG key 0x6D745A60: Userid : "Release Engineering <infrastructure@rockylinux.org>" Fingerprint: 7051 C470 A929 F454 CEBE 37B7 15AF 5DAC 6D74 5A60 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficialKey imported successfullyRunning transaction checkTransaction check succeeded.Running transaction testTransaction test succeeded.Running transaction Preparing : 1/1 Installing : which-2.21-20.el8.x86_64 1/5 Installing : vim-filesystem-2:8.0.1763-19.el8_6.4.noarch 2/5 Installing : vim-common-2:8.0.1763-19.el8_6.4.x86_64 3/5 Installing : gpm-libs-1.20.7-17.el8.x86_64 4/5 Running scriptlet: gpm-libs-1.20.7-17.el8.x86_64 4/5 Installing : vim-enhanced-2:8.0.1763-19.el8_6.4.x86_64 5/5 Running scriptlet: vim-enhanced-2:8.0.1763-19.el8_6.4.x86_64 5/5 Running scriptlet: vim-common-2:8.0.1763-19.el8_6.4.x86_64 5/5 Verifying : gpm-libs-1.20.7-17.el8.x86_64 1/5 Verifying : vim-common-2:8.0.1763-19.el8_6.4.x86_64 2/5 Verifying : vim-enhanced-2:8.0.1763-19.el8_6.4.x86_64 3/5 Verifying : vim-filesystem-2:8.0.1763-19.el8_6.4.noarch 4/5 Verifying : which-2.21-20.el8.x86_64 5/5 Installed: gpm-libs-1.20.7-17.el8.x86_64 vim-common-2:8.0.1763-19.el8_6.4.x86_64 vim-enhanced-2:8.0.1763-19.el8_6.4.x86_64 vim-filesystem-2:8.0.1763-19.el8_6.4.noarch which-2.21-20.el8.x86_64 Complete!Removing intermediate container f88378120cc1 ---> cb9eb843b319Step 6/11 : RUN yum install -y net-tools ---> Running in 15b13dec8321Last metadata expiration check: 0:00:29 ago on Sun Dec 8 07:29:48 2024.Dependencies resolved.================================================================================ Package Architecture Version Repository Size================================================================================Installing: net-tools x86_64 2.0-0.52.20160912git.el8 baseos 321 kTransaction Summary================================================================================Install 1 PackageTotal download size: 321 kInstalled size: 942 kDownloading Packages:net-tools-2.0-0.52.20160912git.el8.x86_64.rpm 262 kB/s | 321 kB 00:01 --------------------------------------------------------------------------------Total 101 kB/s | 321 kB 00:03 Running transaction checkTransaction check succeeded.Running transaction testTransaction test succeeded.Running transaction Preparing : 1/1 Installing : net-tools-2.0-0.52.20160912git.el8.x86_64 1/1 Running scriptlet: net-tools-2.0-0.52.20160912git.el8.x86_64 1/1 Verifying : net-tools-2.0-0.52.20160912git.el8.x86_64 1/1 Installed: net-tools-2.0-0.52.20160912git.el8.x86_64 Complete!Removing intermediate container 15b13dec8321 ---> 2e79057963a9Step 7/11 : RUN mkdir /opt/jdk ---> Running in 69bf76127e8dRemoving intermediate container 69bf76127e8d ---> 25f8d658823fStep 8/11 : ADD jdk-17.0.12_linux-x64_bin.tar.gz /opt/jdk ---> 83d8b92be129Step 9/11 : ENV JAVA_HOME /opt/jdk/jdk-17.0.12 ---> Running in 1f4043adc4cbRemoving intermediate container 1f4043adc4cb ---> 3c05d8189cadStep 10/11 : ENV PATH $JAVA_HOME/bin:$PATH ---> Running in 15d649530173Removing intermediate container 15d649530173 ---> c9f46f990422Step 11/11 : CMD ["/bin/bash"] ---> Running in 02d2ee2073eeRemoving intermediate container 02d2ee2073ee ---> fb5b6a2e5b81Successfully built fb5b6a2e5b81Successfully tagged rockey8_jdk17:1.0.0
提示构建成功,查看一下自己构建的镜像
[root@localhost opt]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZErockey8_jdk17 1.0.0 fb5b6a2e5b81 49 seconds ago 642MBrockylinux 8.9 c79048e50f5f 12 months ago 198MB
原文地址:https://www.rockylinux.cn/notes/rocky-linux-9-network-configuration.html 原文作者:木子 Rocky Linux 中文社区欢迎您 https://www.rockylinux.cn
IPv4 与 IPv6
在进行 IP 配置之前,我们延伸了解一下 IPv4 与 IPv6 。 IPv4(Internet Protocol version 4)和 IPv6(Internet Protocol version 6)是互联网上用于数据包交换的两个版本的网络层协议。它们是互联网协议套件的核心部分,负责在网络设备之间路由和传递数据。
[root@k8s131 ~]# kubeadm init \> --image-repository registry.k8s.io \> --apiserver-advertise-address=192.168.228.131 \> --control-plane-endpoint=cluster-endpoint \> --kubernetes-version=v1.20.9 \> --service-cidr=10.96.0.0/16 \> --pod-network-cidr=192.168.23.0/24 [init] Using Kubernetes version: v1.20.9[preflight] Running pre-flight checks[WARNING Firewalld]: firewalld is active, please ensure ports [6443 10250] are open or your cluster may not function correctly[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.7. Latest validated version: 19.03[preflight] Pulling images required for setting up a Kubernetes cluster[preflight] This might take a minute or two, depending on the speed of your internet connection[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'[certs] Using certificateDir folder "/etc/kubernetes/pki"[certs] Generating "ca" certificate and key[certs] Generating "apiserver" certificate and key[certs] apiserver serving cert is signed for DNS names [cluster-endpoint k8s131 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.228.131][certs] Generating "apiserver-kubelet-client" certificate and key[certs] Generating "front-proxy-ca" certificate and key[certs] Generating "front-proxy-client" certificate and key[certs] Generating "etcd/ca" certificate and key[certs] Generating "etcd/server" certificate and key[certs] etcd/server serving cert is signed for DNS names [k8s131 localhost] and IPs [192.168.228.131 127.0.0.1 ::1][certs] Generating "etcd/peer" certificate and key[certs] etcd/peer serving cert is signed for DNS names [k8s131 localhost] and IPs [192.168.228.131 127.0.0.1 ::1][certs] Generating "etcd/healthcheck-client" certificate and key[certs] Generating "apiserver-etcd-client" certificate and key[certs] Generating "sa" key and public key[kubeconfig] Using kubeconfig folder "/etc/kubernetes"[kubeconfig] Writing "admin.conf" kubeconfig file[kubeconfig] Writing "kubelet.conf" kubeconfig file[kubeconfig] Writing "controller-manager.conf" kubeconfig file[kubeconfig] Writing "scheduler.conf" kubeconfig file[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"[kubelet-start] Starting the kubelet[control-plane] Using manifest folder "/etc/kubernetes/manifests"[control-plane] Creating static Pod manifest for "kube-apiserver"[control-plane] Creating static Pod manifest for "kube-controller-manager"[control-plane] Creating static Pod manifest for "kube-scheduler"[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s[apiclient] All control plane components are healthy after 14.007116 seconds[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace[kubelet] Creating a ConfigMap "kubelet-config-1.20" in namespace kube-system with the configuration for the kubelets in the cluster[upload-certs] Skipping phase. Please see --upload-certs[mark-control-plane] Marking the node k8s131 as control-plane by adding the labels "node-role.kubernetes.io/master=''" and "node-role.kubernetes.io/control-plane='' (deprecated)"[mark-control-plane] Marking the node k8s131 as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule][bootstrap-token] Using token: 4qn4kj.52saric9a3vqnk1w[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles[bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to get nodes[bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials[bootstrap-token] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token[bootstrap-token] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key[addons] Applied essential addon: CoreDNS[addons] Applied essential addon: kube-proxyYour Kubernetes control-plane has initialized successfully!To start using your cluster, you need to run the following as a regular user: mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/configAlternatively, if you are the root user, you can run: export KUBECONFIG=/etc/kubernetes/admin.confYou should now deploy a pod network to the cluster.Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at: https://kubernetes.io/docs/concepts/cluster-administration/addons/You can now join any number of control-plane nodes by copying certificate authoritiesand service account keys on each node and then running the following as root: kubeadm join cluster-endpoint:6443 --token 4qn4kj.52saric9a3vqnk1w \ --discovery-token-ca-cert-hash sha256:7f12181600006aeb62fb38bcb82582809a9ad1911e49065f1fd13f9c68c95774 \ --control-plane Then you can join any number of worker nodes by running the following on each as root:kubeadm join cluster-endpoint:6443 --token 4qn4kj.52saric9a3vqnk1w \ --discovery-token-ca-cert-hash sha256:7f12181600006aeb62fb38bcb82582809a9ad1911e49065f1fd13f9c68c95774
4.配置文件目录
按照上述的输出提示“To start using your cluster, you need to run the following as a regular user” 还需要需要在主节点执行下面的命令
再次输入命令kubectl get nodes -A测试主节点状态,已经变为Ready,准备就绪,网络插件到此部署完成。
[root@k8s131 opt]# kubectl get nodes -ANAME STATUS ROLES AGE VERSIONk8s131 Ready control-plane,master 5h53m v1.20.9
主节点至此初始化完成。
3.6 从节点加入集群
从节点加入集群的命令,在初始化主节点命令输出的内容中就有,在之前复制的输出内容中找到Then you can join any number of worker nodes by running the following on each as root:,并找到它下面的一行命令在每个从节点执行,该命令24小时内有效
[root@k8s132 ~]# kubeadm join cluster-endpoint:6443 --token bjme49.uhg7ubgjn2m16b76 --discovery-token-ca-cert-hash sha256:7f12181600006aeb62fb38bcb82582809a9ad1911e49065f1fd13f9c68c95774[preflight] Running pre-flight checks[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.7. Latest validated version: 19.03[WARNING Hostname]: hostname "k8s132" could not be reached[WARNING Hostname]: hostname "k8s132": lookup k8s132 on 192.168.228.2:53: server misbehaving[preflight] Reading configuration from the cluster...[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"[kubelet-start] Starting the kubelet[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...This node has joined the cluster:* Certificate signing request was sent to apiserver and a response was received.* The Kubelet was informed of the new secure connection details.Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
回到主节点执行命令kubectl get nodes -A,查看节点状态,可以看到两个从节点了,但是状态是NotReady,此时执行kubectl get pods -A查看pods状态,发现是因为从节点的网络插件未初始化成功完成导致,此时需要耐心等待网络插件加载完成,以我的经验来说加载网络插件需要下载很久。
管理集群要靠主节点,kubectl命令只能在主节点执行
[root@k8s131 ~]# kubectl get nodes -ANAME STATUS ROLES AGE VERSIONk8s131 Ready control-plane,master 2d23h v1.20.9k8s132 NotReady <none> 6m49s v1.20.9k8s133 NotReady <none> 6m41s v1.20.9
Visual Studio(特别是其中的 Visual C++ 工具)在 Windows 系统上提供了 C/C++ 编译器和相关工具链,它们是用来编译和链接本地代码的。当使用 GraalVM 在 Windows 上构建本地可执行文件时,需要依赖 Visual Studio 提供的这些编译工具来完成编译和链接的过程。
安装界面,勾选使用C++的桌面开发
等待安装完成后,测试x64 Native Tools Command Prompt for VS 2022
以管理员身份测试打开x64 Native Tools Command Prompt for VS 2022
[INFO] Scanning for projects...[INFO] [INFO] ----------------------< org.example:springboot3 >-----------------------[INFO] Building springboot3 1.0-SNAPSHOT[INFO] --------------------------------[ jar ]---------------------------------[INFO] [INFO] --- native-maven-plugin:0.9.21:build (default-cli) @ springboot3 ---[WARNING] 'native:build' goal is deprecated. Use 'native:compile-no-fork' instead.[INFO] Found GraalVM installation from JAVA_HOME variable.[INFO] Executing: F:\graalvm-ce-java17-22.3.3\bin\native-image.cmd @target\tmp\native-image-3043011469918092793.args========================================================================================================================GraalVM Native Image: Generating 'springboot3' (executable)...========================================================================================================================[1/7] Initializing... (21.0s @ 0.17GB) Version info: 'GraalVM 22.3.3 Java 17 CE' Java version info: '17.0.8+7-jvmci-22.3-b22' C compiler: cl.exe (microsoft, x64, 19.41.34123) Garbage collector: Serial GC 1 user-specific feature(s) - org.springframework.aot.nativex.feature.PreComputeFieldFeatureField org.apache.commons.logging.LogAdapter#log4jSpiPresent set to true at build timeField org.apache.commons.logging.LogAdapter#log4jSlf4jProviderPresent set to true at build timeField org.apache.commons.logging.LogAdapter#slf4jSpiPresent set to true at build timeField org.apache.commons.logging.LogAdapter#slf4jApiPresent set to true at build timeField org.springframework.core.NativeDetector#imageCode set to true at build timeField org.springframework.core.KotlinDetector#kotlinPresent set to false at build timeField org.springframework.core.KotlinDetector#kotlinReflectPresent set to false at build timeField org.springframework.format.support.DefaultFormattingConversionService#jsr354Present set to false at build timeField org.springframework.cglib.core.AbstractClassGenerator#imageCode set to true at build timeField org.springframework.boot.logging.log4j2.Log4J2LoggingSystem$Factory#PRESENT set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#romePresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jaxb2Present set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2Present set to true at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2XmlPresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2SmilePresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2CborPresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#gsonPresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jsonbPresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationCborPresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationJsonPresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationProtobufPresent set to false at build timeField org.springframework.boot.logging.java.JavaLoggingSystem$Factory#PRESENT set to true at build timeField org.springframework.boot.logging.logback.LogbackLoggingSystem$Factory#PRESENT set to true at build timeField org.springframework.http.converter.json.Jackson2ObjectMapperBuilder#jackson2XmlPresent set to false at build timeField org.springframework.web.servlet.view.InternalResourceViewResolver#jstlPresent set to false at build timeField org.springframework.web.context.support.StandardServletEnvironment#jndiPresent set to true at build timeField org.springframework.boot.logging.logback.LogbackLoggingSystemProperties#JBOSS_LOGGING_PRESENT set to false at build timeField org.springframework.web.context.support.WebApplicationContextUtils#jsfPresent set to false at build timeField org.springframework.web.context.request.RequestContextHolder#jsfPresent set to false at build timeField org.springframework.context.event.ApplicationListenerMethodAdapter#reactiveStreamsPresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jaxb2Present set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2Present set to true at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2XmlPresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2SmilePresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#gsonPresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jsonbPresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationCborPresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationJsonPresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationProtobufPresent set to false at build timeField org.springframework.core.ReactiveAdapterRegistry#reactorPresent set to false at build timeField org.springframework.core.ReactiveAdapterRegistry#rxjava3Present set to false at build timeField org.springframework.core.ReactiveAdapterRegistry#kotlinCoroutinesPresent set to false at build timeField org.springframework.core.ReactiveAdapterRegistry#mutinyPresent set to false at build timeField org.springframework.web.client.RestTemplate#romePresent set to false at build timeField org.springframework.web.client.RestTemplate#jaxb2Present set to false at build timeField org.springframework.web.client.RestTemplate#jackson2Present set to true at build timeField org.springframework.web.client.RestTemplate#jackson2XmlPresent set to false at build timeField org.springframework.web.client.RestTemplate#jackson2SmilePresent set to false at build timeField org.springframework.web.client.RestTemplate#jackson2CborPresent set to false at build timeField org.springframework.web.client.RestTemplate#gsonPresent set to false at build timeField org.springframework.web.client.RestTemplate#jsonbPresent set to false at build timeField org.springframework.web.client.RestTemplate#kotlinSerializationCborPresent set to false at build timeField org.springframework.web.client.RestTemplate#kotlinSerializationJsonPresent set to false at build timeField org.springframework.web.client.RestTemplate#kotlinSerializationProtobufPresent set to false at build timeField org.springframework.boot.autoconfigure.web.format.WebConversionService#JSR_354_PRESENT set to false at build timeSLF4J: No SLF4J providers were found.SLF4J: Defaulting to no-operation (NOP) logger implementationSLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.Field org.springframework.web.servlet.mvc.method.annotation.ReactiveTypeHandler#isContextPropagationPresent set to false at build timeField org.springframework.web.servlet.support.RequestContext#jstlPresent set to false at build time[2/7] Performing analysis... [**********] (98.5s @ 1.27GB) 15,315 (92.75%) of 16,513 classes reachable 24,931 (67.59%) of 36,886 fields reachable 73,546 (62.21%) of 118,224 methods reachable 802 classes, 244 fields, and 4,549 methods registered for reflection 83 classes, 78 fields, and 68 methods registered for JNI access 5 native libraries: crypt32, ncrypt, psapi, version, winhttp[3/7] Building universe... (9.2s @ 1.48GB)[4/7] Parsing methods... [**] (3.0s @ 1.71GB)[5/7] Inlining methods... [***] (2.1s @ 1.75GB)[6/7] Compiling methods... [*********] (92.6s @ 1.80GB)[7/7] Creating image... (162.3s @ 1.29GB) 34.44MB (52.32%) for code area: 48,187 compilation units 30.94MB (47.01%) for image heap: 354,772 objects and 118 resources 445.88KB ( 0.66%) for other data 65.81MB in total------------------------------------------------------------------------------------------------------------------------Top 10 packages in code area: Top 10 object types in image heap: 1.64MB sun.security.ssl 7.33MB byte[] for code metadata 1.05MB java.util 3.64MB java.lang.Class 835.67KB java.lang.invoke 3.41MB java.lang.String 725.04KB com.sun.crypto.provider 2.87MB byte[] for general heap data 560.78KB org.apache.catalina.core 2.83MB byte[] for java.lang.String 527.20KB org.apache.tomcat.util.net 1.29MB com.oracle.svm.core.hub.DynamicHubCompanion 495.45KB org.apache.coyote.http2 880.07KB byte[] for reflection metadata 477.20KB java.lang 775.15KB byte[] for embedded resources 470.10KB c.s.org.apache.xerces.internal.impl.xs.traversers 664.68KB java.lang.String[] 467.89KB java.util.concurrent 621.94KB java.util.HashMap$Node 26.94MB for 621 more packages 5.69MB for 3067 more object types------------------------------------------------------------------------------------------------------------------------ 134.1s (26.7% of total time) in 116 GCs | Peak RSS: 2.60GB | CPU load: 3.09------------------------------------------------------------------------------------------------------------------------Produced artifacts: C:\Users\LiuZijian\IdeaProjects\springboot3\target\springboot3.build_artifacts.txt (txt) C:\Users\LiuZijian\IdeaProjects\springboot3\target\springboot3.exe (executable)========================================================================================================================Finished generating 'springboot3' in 8m 20s.[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 08:30 min[INFO] Finished at: 2024-11-14T23:22:01+08:00[INFO] ------------------------------------------------------------------------Process finished with exit code 0
root@lzj-virtual-machine:/opt/springboot3# mvn native:build[INFO] Scanning for projects...[INFO] [INFO] ----------------------< org.example:springboot3 >-----------------------[INFO] Building springboot3 1.0-SNAPSHOT[INFO] from pom.xml[INFO] --------------------------------[ jar ]---------------------------------[INFO] [INFO] --- native:0.9.21:build (default-cli) @ springboot3 ---[WARNING] 'native:build' goal is deprecated. Use 'native:compile-no-fork' instead.[INFO] Found GraalVM installation from JAVA_HOME variable.[INFO] Executing: /opt/graalvm-ce-java17-22.3.3/bin/native-image -cp /opt/springboot3/target/classes:/root/.m2/repository/org/springframework/boot/spring-boot-starter/3.0.6/spring-boot-starter-3.0.6.jar:/root/.m2/repository/ch/qos/logback/logback-classic/1.4.7/logback-classic-1.4.7.jar:/root/.m2/repository/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar:/root/.m2/repository/io/micrometer/micrometer-observation/1.10.6/micrometer-observation-1.10.6.jar:/root/.m2/repository/org/springframework/spring-expression/6.0.8/spring-expression-6.0.8.jar:/root/.m2/repository/ch/qos/logback/logback-core/1.4.7/logback-core-1.4.7.jar:/root/.m2/repository/org/springframework/spring-webmvc/6.0.8/spring-webmvc-6.0.8.jar:/root/.m2/repository/org/springframework/boot/spring-boot/3.0.6/spring-boot-3.0.6.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-logging/3.0.6/spring-boot-starter-logging-3.0.6.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-json/3.0.6/spring-boot-starter-json-3.0.6.jar:/root/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.14.2/jackson-datatype-jsr310-2.14.2.jar:/root/.m2/repository/org/springframework/spring-aop/6.0.8/spring-aop-6.0.8.jar:/root/.m2/repository/jakarta/annotation/jakarta.annotation-api/2.1.1/jakarta.annotation-api-2.1.1.jar:/root/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/10.1.8/tomcat-embed-websocket-10.1.8.jar:/root/.m2/repository/org/springframework/spring-context/6.0.8/spring-context-6.0.8.jar:/root/.m2/repository/org/slf4j/jul-to-slf4j/2.0.7/jul-to-slf4j-2.0.7.jar:/root/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.14.2/jackson-databind-2.14.2.jar:/root/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.14.2/jackson-datatype-jdk8-2.14.2.jar:/root/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/3.0.6/spring-boot-autoconfigure-3.0.6.jar:/root/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/10.1.8/tomcat-embed-el-10.1.8.jar:/root/.m2/repository/io/micrometer/micrometer-commons/1.10.6/micrometer-commons-1.10.6.jar:/root/.m2/repository/org/apache/logging/log4j/log4j-api/2.19.0/log4j-api-2.19.0.jar:/root/.m2/repository/org/springframework/spring-web/6.0.8/spring-web-6.0.8.jar:/root/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.14.2/jackson-module-parameter-names-2.14.2.jar:/root/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.19.0/log4j-to-slf4j-2.19.0.jar:/root/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/10.1.8/tomcat-embed-core-10.1.8.jar:/root/.m2/repository/org/springframework/spring-core/6.0.8/spring-core-6.0.8.jar:/root/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.14.2/jackson-annotations-2.14.2.jar:/root/.m2/repository/org/yaml/snakeyaml/1.33/snakeyaml-1.33.jar:/root/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.14.2/jackson-core-2.14.2.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-web/3.0.6/spring-boot-starter-web-3.0.6.jar:/root/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/3.0.6/spring-boot-starter-tomcat-3.0.6.jar:/root/.m2/repository/org/springframework/spring-jcl/6.0.8/spring-jcl-6.0.8.jar:/root/.m2/repository/org/springframework/spring-beans/6.0.8/spring-beans-6.0.8.jar --no-fallback -H:Path=/opt/springboot3/target -H:Name=springboot3========================================================================================================================GraalVM Native Image: Generating 'springboot3' (executable)...========================================================================================================================[1/7] Initializing... (38.9s @ 0.18GB) Version info: 'GraalVM 22.3.3 Java 17 CE' Java version info: '17.0.8+7-jvmci-22.3-b22' C compiler: gcc (linux, x86_64, 11.4.0) Garbage collector: Serial GC 1 user-specific feature(s) - org.springframework.aot.nativex.feature.PreComputeFieldFeatureField org.springframework.core.NativeDetector#imageCode set to true at build timeField org.apache.commons.logging.LogAdapter#log4jSpiPresent set to true at build timeField org.apache.commons.logging.LogAdapter#log4jSlf4jProviderPresent set to true at build timeField org.apache.commons.logging.LogAdapter#slf4jSpiPresent set to true at build timeField org.apache.commons.logging.LogAdapter#slf4jApiPresent set to true at build timeField org.springframework.core.KotlinDetector#kotlinPresent set to false at build timeField org.springframework.core.KotlinDetector#kotlinReflectPresent set to false at build timeField org.springframework.cglib.core.AbstractClassGenerator#imageCode set to true at build timeField org.springframework.format.support.DefaultFormattingConversionService#jsr354Present set to false at build timeField org.springframework.boot.logging.logback.LogbackLoggingSystem$Factory#PRESENT set to true at build timeField org.springframework.web.servlet.view.InternalResourceViewResolver#jstlPresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#romePresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jaxb2Present set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2Present set to true at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2XmlPresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2SmilePresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2CborPresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#gsonPresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jsonbPresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationCborPresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationJsonPresent set to false at build timeField org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationProtobufPresent set to false at build timeField org.springframework.boot.logging.log4j2.Log4J2LoggingSystem$Factory#PRESENT set to false at build timeField org.springframework.boot.logging.java.JavaLoggingSystem$Factory#PRESENT set to true at build timeField org.springframework.http.converter.json.Jackson2ObjectMapperBuilder#jackson2XmlPresent set to false at build timeField org.springframework.web.context.support.StandardServletEnvironment#jndiPresent set to true at build timeField org.springframework.web.context.support.WebApplicationContextUtils#jsfPresent set to false at build timeField org.springframework.web.context.request.RequestContextHolder#jsfPresent set to false at build timeField org.springframework.boot.logging.logback.LogbackLoggingSystemProperties#JBOSS_LOGGING_PRESENT set to false at build timeField org.springframework.context.event.ApplicationListenerMethodAdapter#reactiveStreamsPresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jaxb2Present set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2Present set to true at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2XmlPresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2SmilePresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#gsonPresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jsonbPresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationCborPresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationJsonPresent set to false at build timeField org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationProtobufPresent set to false at build timeField org.springframework.web.client.RestTemplate#romePresent set to false at build timeField org.springframework.web.client.RestTemplate#jaxb2Present set to false at build timeField org.springframework.web.client.RestTemplate#jackson2Present set to true at build timeField org.springframework.web.client.RestTemplate#jackson2XmlPresent set to false at build timeField org.springframework.web.client.RestTemplate#jackson2SmilePresent set to false at build timeField org.springframework.web.client.RestTemplate#jackson2CborPresent set to false at build timeField org.springframework.web.client.RestTemplate#gsonPresent set to false at build timeField org.springframework.web.client.RestTemplate#jsonbPresent set to false at build timeField org.springframework.web.client.RestTemplate#kotlinSerializationCborPresent set to false at build timeField org.springframework.web.client.RestTemplate#kotlinSerializationJsonPresent set to false at build timeField org.springframework.web.client.RestTemplate#kotlinSerializationProtobufPresent set to false at build timeField org.springframework.core.ReactiveAdapterRegistry#reactorPresent set to false at build timeField org.springframework.core.ReactiveAdapterRegistry#rxjava3Present set to false at build timeField org.springframework.core.ReactiveAdapterRegistry#kotlinCoroutinesPresent set to false at build timeField org.springframework.core.ReactiveAdapterRegistry#mutinyPresent set to false at build timeField org.springframework.boot.autoconfigure.web.format.WebConversionService#JSR_354_PRESENT set to false at build timeSLF4J: No SLF4J providers were found.SLF4J: Defaulting to no-operation (NOP) logger implementationSLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.Field org.springframework.web.servlet.mvc.method.annotation.ReactiveTypeHandler#isContextPropagationPresent set to false at build timeField org.springframework.web.servlet.support.RequestContext#jstlPresent set to false at build time[2/7] Performing analysis... [*********] (450.4s @ 2.25GB) 15,331 (92.43%) of 16,586 classes reachable 24,926 (67.58%) of 36,883 fields reachable 73,471 (62.05%) of 118,406 methods reachable 784 classes, 246 fields, and 4,536 methods registered for reflection 64 classes, 70 fields, and 55 methods registered for JNI access 4 native libraries: dl, pthread, rt, z[3/7] Building universe... (71.4s @ 1.81GB)[4/7] Parsing methods... [*******] (48.4s @ 1.67GB)[5/7] Inlining methods... [***] (18.7s @ 2.49GB)[6/7] Compiling methods... [**********] (112.1s @ 2.00GB)[7/7] Creating image... (53.6s @ 2.85GB) 33.97MB (51.08%) for code area: 48,119 compilation units 29.90MB (44.97%) for image heap: 353,714 objects and 118 resources 2.63MB ( 3.96%) for other data 66.50MB in total------------------------------------------------------------------------------------------------------------------------Top 10 packages in code area: Top 10 object types in image heap: 1.63MB sun.security.ssl 7.29MB byte[] for code metadata 1.04MB java.util 3.64MB java.lang.Class 829.18KB java.lang.invoke 3.41MB java.lang.String 717.16KB com.sun.crypto.provider 2.86MB byte[] for general heap data 558.99KB org.apache.catalina.core 2.82MB byte[] for java.lang.String 519.74KB org.apache.tomcat.util.net 1.29MB com.oracle.svm.core.hub.DynamicHubCompanion 491.53KB org.apache.coyote.http2 878.75KB byte[] for reflection metadata 476.53KB java.lang 775.14KB byte[] for embedded resources 467.23KB c.s.org.apache.xerces.internal.impl.xs.traversers 664.31KB java.lang.String[] 461.61KB sun.security.x509 619.31KB java.util.HashMap$Node 26.53MB for 628 more packages 5.45MB for 3069 more object types------------------------------------------------------------------------------------------------------------------------ 189.1s (21.7% of total time) in 60 GCs | Peak RSS: 4.14GB | CPU load: 8.45------------------------------------------------------------------------------------------------------------------------Produced artifacts: /opt/springboot3/target/springboot3 (executable) /opt/springboot3/target/springboot3.build_artifacts.txt (txt)========================================================================================================================Finished generating 'springboot3' in 14m 28s.[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 14:40 min[INFO] Finished at: 2024-11-16T00:59:34+08:00[INFO] ------------------------------------------------------------------------
publicenumState{/** * Thread state for a thread which has not yet started. */NEW,/** * Thread state for a runnable thread. A thread in the runnable * state is executing in the Java virtual machine but it may * be waiting for other resources from the operating system * such as processor. */RUNNABLE,/** * Thread state for a thread blocked waiting for a monitor lock. * A thread in the blocked state is waiting for a monitor lock * to enter a synchronized block/method or * reenter a synchronized block/method after calling * {@link Object#wait() Object.wait}. */BLOCKED,/** * Thread state for a waiting thread. * A thread is in the waiting state due to calling one of the * following methods: * <ul> * <li>{@link Object#wait() Object.wait} with no timeout</li> * <li>{@link #join() Thread.join} with no timeout</li> * <li>{@link LockSupport#park() LockSupport.park}</li> * </ul> * * <p>A thread in the waiting state is waiting for another thread to * perform a particular action. * * For example, a thread that has called <tt>Object.wait()</tt> * on an object is waiting for another thread to call * <tt>Object.notify()</tt> or <tt>Object.notifyAll()</tt> on * that object. A thread that has called <tt>Thread.join()</tt> * is waiting for a specified thread to terminate. */WAITING,/** * Thread state for a waiting thread with a specified waiting time. * A thread is in the timed waiting state due to calling one of * the following methods with a specified positive waiting time: * <ul> * <li>{@link #sleep Thread.sleep}</li> * <li>{@link Object#wait(long) Object.wait} with timeout</li> * <li>{@link #join(long) Thread.join} with timeout</li> * <li>{@link LockSupport#parkNanos LockSupport.parkNanos}</li> * <li>{@link LockSupport#parkUntil LockSupport.parkUntil}</li> * </ul> */TIMED_WAITING,/** * Thread state for a terminated thread. * The thread has completed execution. */TERMINATED;}
[root@localhost bin]# ./redis-server ./redis.conf5837:C 04 Feb 2025 13:15:52.211 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.5837:C 04 Feb 2025 13:15:52.212 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo5837:C 04 Feb 2025 13:15:52.213 * Redis version=7.2.6, bits=64, commit=00000000, modified=0, pid=5837, just started5837:C 04 Feb 2025 13:15:52.213 * Configuration loaded5837:M 04 Feb 2025 13:15:52.214 * Increased maximum number of open files to 10032 (it was originally set to 1024).5837:M 04 Feb 2025 13:15:52.215 * monotonic clock: POSIX clock_gettime _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 7.2.6 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 5837 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | https://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 5837:M 04 Feb 2025 13:15:52.224 * Server initialized5837:M 04 Feb 2025 13:15:52.224 * Ready to accept connections tcp
出现这个界面就说明启动成功了。
4.简单设置
vim redis.conf配置文件,进行以下修改,完成后重启redis-server
1.默认daemonize no 改为 daemonize yes,让redis从后台启动。
# By default Redis does not run as a daemon. Use 'yes' if you need it.# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.# When Redis is supervised by upstart or systemd, this parameter has no impact.daemonize yes
# Protected mode is a layer of security protection, in order to avoid that# Redis instances left open on the internet are accessed and exploited.## When protected mode is on and the default user has no password, the server# only accepts local connections from the IPv4 address (127.0.0.1), IPv6 address# (::1) or Unix domain sockets.## By default protected mode is enabled. You should disable it only if# you are sure you want clients from other hosts to connect to Redis# even if no authentication is configured.protected-mode no
# By default, if no "bind" configuration directive is specified, Redis listens# for connections from all available network interfaces on the host machine.# It is possible to listen to just one or multiple selected interfaces using# the "bind" configuration directive, followed by one or more IP addresses.# Each address can be prefixed by "-", which means that redis will not fail to# start if the address is not available. Being not available only refers to# addresses that does not correspond to any network interface. Addresses that# are already in use will always fail, and unsupported protocols will always BE# silently skipped.## Examples:## bind 192.168.1.100 10.0.0.1 # listens on two specific IPv4 addresses# bind 127.0.0.1 ::1 # listens on loopback IPv4 and IPv6# bind * -::* # like the default, all available interfaces## ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the# internet, binding to all the interfaces is dangerous and will expose the# instance to everybody on the internet. So by default we uncomment the# following bind directive, that will force Redis to listen only on the# IPv4 and IPv6 (if available) loopback interface addresses (this means Redis# will only be able to accept client connections from the same host that it is# running on).## IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES# COMMENT OUT THE FOLLOWING LINE.## You will also need to set a password unless you explicitly disable protected# mode.# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~bind 0.0.0.0
# IMPORTANT NOTE: starting with Redis 6 "requirepass" is just a compatibility# layer on top of the new ACL system. The option effect will be just setting# the password for the default user. Clients will still authenticate using# AUTH <password> as usually, or more explicitly with AUTH default <password># if they follow the new protocol: both will work.## The requirepass is not compatible with aclfile option and the ACL LOAD# command, these will cause requirepass to be ignored.#requirepass lzj
[root@localhost bin]# ./redis-cli -a lzj -p 6379 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.127.0.0.1:6379> pingPONG127.0.0.1:6379> quit[root@localhost bin]#
UnionFS(联合文件系统)是一种分层,轻量级并且高性能的文件系统,它支持对文件系统的修改作为一次次的提交来一层一层的叠加,同时可以将不同目录挂载到同一个虚拟文件系统下(unite several directories into a single virtual filesystem)。联合文件系统是docker镜像的基础,镜像可以通过分层来实现继承,基于基础镜像(没有父镜像),可以制作各种具体的应用镜像。
[root@localhost ~]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES38188376416b tomcat "catalina.sh run" About a minute ago Up About a minute 8080/tcp inspiring_austin
宿主机执行ip addr查看宿主机的网络情况
[root@localhost ~]# ip addr1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:44:65:de brd ff:ff:ff:ff:ff:ff inet 192.168.228.104/24 brd 192.168.228.255 scope global noprefixroute ens33 valid_lft forever preferred_lft forever inet6 fe80::2ac6:ec4:9411:4da8/64 scope link noprefixroute valid_lft forever preferred_lft forever3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ff:ca:bc:ec brd ff:ff:ff:ff:ff:ff inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0 valid_lft forever preferred_lft forever inet6 fe80::42:ffff:feca:bcec/64 scope link valid_lft forever preferred_lft forever15: vethc5f3f03@if14: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default link/ether 26:9a:2e:de:95:5a brd ff:ff:ff:ff:ff:ff link-netnsid 1 inet6 fe80::249a:2eff:fede:955a/64 scope link valid_lft forever preferred_lft forever
验证:先启动一个tomcat容器tomcat86,该容器内的程序会占用容器的8080,在启动另一个tomcat容器tomcat87和前者共享网络,因为也是基于tomcat镜像,所以同样会占用容器的8080,两个容器端口范围是共享的,导致报错Error response from daemon: conflicting options: port publishing and the container type network mode.
docker run -d--privileged=true -p8086:8080 --name tomcat86 tomcatdocker run -d--privileged=true -p8086:8080 --network container:tomcat86 --name tomcat87 tomcat
[root@localhost ~]# docker run -d --privileged=true -p 8086:8080 --name tomcat86 tomcatc8464b5448296b51bc5b4e4598acce709513aa6ac7fac6ef335e5a39e8a785f3[root@localhost ~]# [root@localhost ~]# [root@localhost ~]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESc8464b544829 tomcat "catalina.sh run" 4 seconds ago Up 2 seconds 0.0.0.0:8086->8080/tcp tomcat860bad9102a5a7 alpine "/bin/sh" 11 minutes ago Up 11 minutes alpine1[root@localhost ~]# [root@localhost ~]# [root@localhost ~]# [root@localhost ~]# docker run -d --privileged=true -p 8086:8080 --network container:tomcat86 --name tomcat87 tomcatdocker: Error response from daemon: conflicting options: port publishing and the container type network mode.See 'docker run --help'.