<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>docker &#8211; Lhy&#039;s blog</title>
	<atom:link href="https://blog.lhyshome.com/tag/docker/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.lhyshome.com</link>
	<description>welcome</description>
	<lastBuildDate>Tue, 22 Apr 2025 03:27:47 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">219834889</site>	<item>
		<title>prometheus部署</title>
		<link>https://blog.lhyshome.com/2025/04/22/294/</link>
					<comments>https://blog.lhyshome.com/2025/04/22/294/#respond</comments>
		
		<dc:creator><![CDATA[lhy]]></dc:creator>
		<pubDate>Tue, 22 Apr 2025 03:23:57 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[grafana]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[prometheus]]></category>
		<guid isPermaLink="false">https://blog.lhyshome.com/?p=294</guid>

					<description><![CDATA[prometheus docker部署 prometheus.yml 配置文件 grafana docker部… <span class="read-more"><a href="https://blog.lhyshome.com/2025/04/22/294/">Read More &#187;</a></span>]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">prometheus docker部署</h2>



<pre class="wp-block-code"><code>docker run -d \
--name=prometheus \
-p 9090:9090 \
-v /home/prometheus/config/prometheus.yml:/etc/prometheus/prometheus.yml \
-v /home/prometheus/prometheus:/prometheus \
{harborPath}/prom/prometheus:v3.3.0</code></pre>



<h3 class="wp-block-heading">prometheus.yml 配置文件</h3>



<pre class="wp-block-code"><code># my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=&lt;job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: &#91;"{prometheus.path}"]
       # The label name is added as a label `label_name=&lt;label_value>` to any timeseries scraped from this config.
        labels:
          app: "prometheus"

  - job_name: 'Aserver'
    static_configs:
      - targets: &#91; '{Aserver.path}' ]
        labels:
          app: "Aserver"
  - job_name: 'Bserver'
    static_configs:
      - targets: &#91; '{Bserver.path}' ]
        labels:
          app: "Bserver"

  - job_name: '200mysql'
    static_configs:
      - targets: &#91;'{mysql.path}']
        labels:
          instance: "200mysql"
          app: "200mysql"</code></pre>



<h2 class="wp-block-heading">grafana docker部署</h2>



<pre class="wp-block-code"><code>docker run -d \
--name=grafana \
-p 3000:3000 \
-v /home/grafana/grafana:/var/lib/grafana \
-e "GF_SECURITY_ADMIN_PASSWORD={password}" \
{harborPath}/grafana/grafana:11.6.0</code></pre>



<h2 class="wp-block-heading">服务器监控收集器 docker部署</h2>



<pre class="wp-block-code"><code>docker run -d \
--name 200-exporter \
--restart=always \
-p 9100:9100 \
-v /proc:/host/proc:ro \
-v /sys:/host/sys:ro \
-v /:/rootfs:ro \
{harborPath}/prom/node-exporter:241003</code></pre>



<h2 class="wp-block-heading">mysql监控收集器 docker部署</h2>



<pre class="wp-block-code"><code>docker run -d \
-p 9104:9104 \
--name=mysqld-exporter \
-v /home/prometheus/mysql/.my.cnf:/.my.cnf \
{harborPath}/prom/mysqld-exporter:v0.17.2</code></pre>



<h3 class="wp-block-heading">.my.cnf 配置文件</h3>



<pre class="wp-block-code"><code>&#91;client]
user={mysql.user}
password={mysql.password}
host={mysql.host}
port={mysql.port}</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.lhyshome.com/2025/04/22/294/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">294</post-id>	</item>
		<item>
		<title>docker创建proxy-client镜像（设置 -e 参数配置）</title>
		<link>https://blog.lhyshome.com/2024/12/30/257/</link>
					<comments>https://blog.lhyshome.com/2024/12/30/257/#respond</comments>
		
		<dc:creator><![CDATA[lhy]]></dc:creator>
		<pubDate>Mon, 30 Dec 2024 03:04:33 +0000</pubDate>
				<category><![CDATA[java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[小技巧]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[harbor]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[proxy-client]]></category>
		<category><![CDATA[内网穿透]]></category>
		<guid isPermaLink="false">https://blog.lhyshome.com/?p=257</guid>

					<description><![CDATA[文件夹目录 dockerFile ep.sh config.template docker构建及上传 进入pr… <span class="read-more"><a href="https://blog.lhyshome.com/2024/12/30/257/">Read More &#187;</a></span>]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">文件夹目录</h2>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="321" height="392" src="https://blog.lhyshome.com/wp-content/uploads/2024/12/image-2.png" alt="" class="wp-image-259" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/12/image-2.png 321w, https://blog.lhyshome.com/wp-content/uploads/2024/12/image-2-246x300.png 246w" sizes="(max-width: 321px) 100vw, 321px" /></figure>



<h2 class="wp-block-heading">dockerFile</h2>



<pre class="wp-block-code"><code>FROM {harbor}/test/openjdk:8-jre
LABEL authors="lhyshome_pc"
ENV TZ=Asia/Shanghai
ADD ./proxy-client /proxy-client
ADD ./ep.sh /ep.sh
RUN apt-get update &amp;&amp; apt-get install -y procps
RUN apt-get update &amp;&amp; apt-get install -y dos2unix
RUN dos2unix /ep.sh &amp;&amp; chmod +x /ep.sh
ENTRYPOINT &#91;"/ep.sh"]</code></pre>



<h2 class="wp-block-heading">ep.sh </h2>



<pre class="wp-block-code"><code>#!/bin/bash

echo "entrypoint.sh start"
# 定义目标配置文件路径
CONFIG_FILE=proxy-client/conf/config.properties

# 替换占位符为环境变量的值
sed -e "s|{{CLIENT_KEY}}|${CLIENT_KEY:-CLIENT_KEY}|g" \
    -e "s|{{SERVER_HOST}}|${SERVER_HOST:-127.0.0.1}|g" \
    -e "s|{{SERVER_PORT}}|${SERVER_PORT:-80}|g" \
    proxy-client/conf/config.template > $CONFIG_FILE

echo "Generated config file:"
cat $CONFIG_FILE

# 启动主程序（根据需要替换为实际启动命令）
exec "proxy-client/bin/startup.sh"</code></pre>



<h2 class="wp-block-heading">config.template</h2>



<pre class="wp-block-code"><code>client.key={{CLIENT_KEY}}
server.host={{SERVER_HOST}}
server.port={{SERVER_PORT}}</code></pre>



<h2 class="wp-block-heading">docker构建及上传</h2>



<p>进入proxy-client的上级目录</p>



<pre class="wp-block-code"><code>docker build -t {harbor}/test/proxy-client:v1.0.0 ./
docker push {harbor}/test/proxy-client:v1.0.0
docker image rm {harbor}/test/proxy-client:v1.0.0</code></pre>



<h2 class="wp-block-heading">docker部署命令</h2>



<p>docker run -e CLIENT_KEY=xxxxx -e SERVER_HOST=xxx.xxx.xxx.xxx -e SERVER_PORT=xxxx &#8211;name proxy-client &#8211;privileged=true &#8211;restart=always -d {harbor}/test/proxy-client:v1.0.0</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.lhyshome.com/2024/12/30/257/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">257</post-id>	</item>
		<item>
		<title>Linux配置代理</title>
		<link>https://blog.lhyshome.com/2024/12/23/250/</link>
					<comments>https://blog.lhyshome.com/2024/12/23/250/#respond</comments>
		
		<dc:creator><![CDATA[lhy]]></dc:creator>
		<pubDate>Mon, 23 Dec 2024 07:46:21 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[小技巧]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://blog.lhyshome.com/?p=250</guid>

					<description><![CDATA[命令行配置代理 配置环境变量 在命令行工具中使用代理，需要在环境变量中明确指定。 配置步骤： 编辑环境变量文件… <span class="read-more"><a href="https://blog.lhyshome.com/2024/12/23/250/">Read More &#187;</a></span>]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">命令行配置代理</h2>



<h3 class="wp-block-heading"><strong>配置环境变量</strong></h3>



<p>在命令行工具中使用代理，需要在环境变量中明确指定。</p>



<h3 class="wp-block-heading">配置步骤：</h3>



<h3 class="wp-block-heading"><strong>编辑环境变量文件</strong> </h3>



<p>打开当前用户的 <code>~/.bashrc</code> 文件：</p>



<pre class="wp-block-code"><code><code>nano ~/.bashrc</code></code></pre>



<h3 class="wp-block-heading"><strong>添加代理环境变量</strong> </h3>



<p>根据代理类型（HTTP/HTTPS/FTP），添加以下内容：</p>



<pre class="wp-block-code"><code>export http_proxy=http://proxy.example.com:8080 
export https_proxy=http://proxy.example.com:8080 
export ftp_proxy=http://proxy.example.com:8080 
<code>export no_proxy=localhost,127.0.0.1,::1 </code></code></pre>



<p>如果代理需要认证，则添加用户名和密码：</p>



<pre class="wp-block-code"><code><code>export http_proxy=http://username:password@proxy.example.com:8080 </code>export https_proxy=http://username:password@proxy.example.com:8080</code></pre>



<h3 class="wp-block-heading"><strong>刷新环境变量</strong> </h3>



<p>保存文件后，运行以下命令使配置生效：</p>



<pre class="wp-block-code"><code><code>source ~/.bashrc</code></code></pre>



<h3 class="wp-block-heading">验证配置 </h3>



<p>查看环境变量是否已生效：</p>



<pre class="wp-block-code"><code><code>echo $http_proxy</code></code></pre>



<h2 class="wp-block-heading">Docker 客户端配置代理</h2>



<h3 class="wp-block-heading">前提</h3>



<p>Error response from daemon: Get &#8220;https://registry-1.docker.io/v2/&#8221;: context deadline exceeded (Client.Timeout exceeded while awaiting headers)</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="86" src="https://blog.lhyshome.com/wp-content/uploads/2024/12/image-1024x86.png" alt="" class="wp-image-251" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/12/image-1024x86.png 1024w, https://blog.lhyshome.com/wp-content/uploads/2024/12/image-300x25.png 300w, https://blog.lhyshome.com/wp-content/uploads/2024/12/image-768x65.png 768w, https://blog.lhyshome.com/wp-content/uploads/2024/12/image-500x42.png 500w, https://blog.lhyshome.com/wp-content/uploads/2024/12/image-800x67.png 800w, https://blog.lhyshome.com/wp-content/uploads/2024/12/image-1280x108.png 1280w, https://blog.lhyshome.com/wp-content/uploads/2024/12/image-660x55.png 660w, https://blog.lhyshome.com/wp-content/uploads/2024/12/image.png 1381w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>因为没有代理，所以docker客户端无法访问dockerhub的默认仓库 https://registry-1.docker.io/v2/ 地址</p>



<h3 class="wp-block-heading"><strong>配置代理</strong></h3>



<p>如果您的网络需要通过代理访问外网，您需要在 Docker 中配置代理。</p>



<h4 class="wp-block-heading">配置步骤：</h4>



<h5 class="wp-block-heading"><strong>创建 Docker 配置目录（如果不存在）：</strong></h5>



<pre class="wp-block-code"><code>mkdir -p /etc/systemd/system/docker.service.d</code></pre>



<h5 class="wp-block-heading"><strong>创建或编辑 <code>http-proxy.conf</code> 文件：</strong></h5>



<pre class="wp-block-code"><code>nano /etc/systemd/system/docker.service.d/http-proxy.conf</code></pre>



<h5 class="wp-block-heading"><strong>添加以下内容：</strong> </h5>



<pre class="wp-block-code"><code># 根据实际代理信息替换 <span style="background-color: initial; font-family: inherit; font-size: inherit; color: initial;">http://proxy.example.com:8080 </span>
<code>Environment="HTTP_PROXY=http://proxy.example.com:8080" Environment="HTTPS_PROXY=http://proxy.example.com:8080" Environment="NO_PROXY=localhost,127.0.0.1"</code></code></pre>



<h5 class="wp-block-heading"><strong>重载并重启 Docker 服务：</strong></h5>



<pre class="wp-block-code"><code>systemctl daemon-reload
systemctl restart docker</code></pre>



<h5 class="wp-block-heading"><strong>验证代理配置是否生效：</strong></h5>



<pre class="wp-block-code"><code><code>docker info | grep -i proxy</code></code></pre>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.lhyshome.com/2024/12/23/250/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">250</post-id>	</item>
		<item>
		<title>基于kkFileView的文件预览，docker部署</title>
		<link>https://blog.lhyshome.com/2024/08/15/209/</link>
					<comments>https://blog.lhyshome.com/2024/08/15/209/#respond</comments>
		
		<dc:creator><![CDATA[lhy]]></dc:creator>
		<pubDate>Thu, 15 Aug 2024 02:53:14 +0000</pubDate>
				<category><![CDATA[java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[小技巧]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[kkFileView]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://blog.lhyshome.com/?p=209</guid>

					<description><![CDATA[下载 github下载地址：https://github.com/kekingcn/kkFileView 下载… <span class="read-more"><a href="https://blog.lhyshome.com/2024/08/15/209/">Read More &#187;</a></span>]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">下载</h2>



<p>github下载地址：<br>https://github.com/kekingcn/kkFileView</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="543" src="https://blog.lhyshome.com/wp-content/uploads/2024/08/image-1-1024x543.png" alt="" class="wp-image-210" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/08/image-1-1024x543.png 1024w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-1-300x159.png 300w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-1-768x407.png 768w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-1-1536x815.png 1536w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-1-500x265.png 500w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-1-800x424.png 800w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-1-1280x679.png 1280w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-1-660x350.png 660w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-1.png 1587w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>下载源码的zip包</p>



<h2 class="wp-block-heading">安装</h2>



<p>将下载的源码打开后，将源码docker路径下的文件夹上传至服务器</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="391" height="592" src="https://blog.lhyshome.com/wp-content/uploads/2024/08/image-2.png" alt="" class="wp-image-211" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/08/image-2.png 391w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-2-198x300.png 198w" sizes="auto, (max-width: 391px) 100vw, 391px" /></figure>



<p>在服务器执行docker build ../../Dockerfile 构建kkFileView的运行的基板</p>



<p>对源码 maven package后将server/target下的 kkFileView-4.4.0-beta.tar.gz 文件和根目录的Dockerfile（注意这里的Dockerfile和之前步骤的Dockerfile不是同一个，作用也不一样）上传至服务器</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="330" height="646" src="https://blog.lhyshome.com/wp-content/uploads/2024/08/image-3.png" alt="" class="wp-image-212" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/08/image-3.png 330w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-3-153x300.png 153w" sizes="auto, (max-width: 330px) 100vw, 330px" /></figure>



<p>修改Dockerfile中的 ADD ./kkFileView-4.4.0-beta.tar.gz /opt/ 这一行  将kkFileView-4.4.0-beta.tar.gz的路径改为服务器上对应的 绝对路径或者相对路径，对当前DockerFile执行docker build ，构建完成后将会出现kkFileView的执行docker镜像</p>



<p>用docker run启动当前镜像 暴露8012端口到宿主机</p>



<p>在服务器防火墙上对8012端口放行</p>



<h2 class="wp-block-heading">验证</h2>



<p>http://服务器ip:8012</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="596" src="https://blog.lhyshome.com/wp-content/uploads/2024/08/image-4-1024x596.png" alt="" class="wp-image-213" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/08/image-4-1024x596.png 1024w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-4-300x175.png 300w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-4-768x447.png 768w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-4-500x291.png 500w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-4-800x466.png 800w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-4-1280x745.png 1280w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-4-660x384.png 660w, https://blog.lhyshome.com/wp-content/uploads/2024/08/image-4.png 1522w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>出现这个页面则为部署成功</p>



<p>http://服务器ip:8012/onlinePreview?url=aHR0cDovLzE5Mi4xNjguMC4yMDA6NTI0NC9wL0Rvd25sb2Fkcy8lRTYlOTYlQjAlRTUlQkIlQkElRTYlOTYlODclRTYlQTElQTMuZG9jeD9zaWduPW53RHB2MVhoS2NXQ3pPODVfa2tPbE85MFo1NGp2YnNXdXA0VlRacnlmaUU9OjA%3D</p>



<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">注意http://服务器ip:8012/onlinePreview?url= 后拼接的地址为文件下载地址，且必须经过base64编码后的请求地址</mark></p>



<h2 class="wp-block-heading">官方操作文档</h2>



<p>https://kkfileview.keking.cn</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.lhyshome.com/2024/08/15/209/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">209</post-id>	</item>
		<item>
		<title>Linux系统docker安装AList</title>
		<link>https://blog.lhyshome.com/2024/07/25/183/</link>
					<comments>https://blog.lhyshome.com/2024/07/25/183/#respond</comments>
		
		<dc:creator><![CDATA[lhy]]></dc:creator>
		<pubDate>Thu, 25 Jul 2024 01:08:42 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[AList]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://blog.lhyshome.com/?p=183</guid>

					<description><![CDATA[docker命令 执行后docker容器的log中会展示出admin账号的密码 页面登陆127.0.0.1:5… <span class="read-more"><a href="https://blog.lhyshome.com/2024/07/25/183/">Read More &#187;</a></span>]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">docker命令</h2>



<pre class="wp-block-code"><code>docker run -d --restart=unless-stopped -v /home/alist:/opt/alist/data -p 5244:5244 -e PUID=0 -e PGID=0 -e UMASK=022 --name="alist" xhofe/alist:v3.36.0</code></pre>



<p>执行后docker容器的log中会展示出admin账号的密码</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="199" src="https://blog.lhyshome.com/wp-content/uploads/2024/07/image-2-1024x199.png" alt="" class="wp-image-184" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/07/image-2-1024x199.png 1024w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-2-300x58.png 300w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-2-768x149.png 768w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-2-500x97.png 500w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-2-800x156.png 800w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-2-1280x249.png 1280w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-2-660x128.png 660w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-2.png 1414w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>页面登陆127.0.0.1:5244</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="601" height="574" src="https://blog.lhyshome.com/wp-content/uploads/2024/07/image-3.png" alt="" class="wp-image-185" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/07/image-3.png 601w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-3-300x287.png 300w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-3-500x478.png 500w" sizes="auto, (max-width: 601px) 100vw, 601px" /></figure>



<p>看到该页面即部署成功</p>



<h2 class="wp-block-heading">nginx配置（可选）</h2>



<p>如果需要使用域名访问，nginx反向代理如下</p>



<pre class="wp-block-preformatted">upstream alist {<br>    server 127.0.0.1:5244 ;<br>}<br><br>server {<br>    listen 80;<br>    server_name alist.example.com;<br>    location / {<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto $scheme;<br>        proxy_set_header Host $http_host;<br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header Range $http_range;<br>        proxy_set_header If-Range $http_if_range;<br>        proxy_redirect off;<br>        # the max size of file to upload<br>        client_max_body_size 20000m;<br>        proxy_pass http://alist;<br>    }<br>}</pre>



<h2 class="wp-block-heading">AList官方文档</h2>



<p>https://alist.nn.ci/zh</p>



<h2 class="wp-block-heading">AList github地址</h2>



<p>https://github.com/alist-org/alist/tree/main</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.lhyshome.com/2024/07/25/183/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">183</post-id>	</item>
		<item>
		<title>Linux下docker添加阿里镜像源</title>
		<link>https://blog.lhyshome.com/2024/07/15/166/</link>
					<comments>https://blog.lhyshome.com/2024/07/15/166/#respond</comments>
		
		<dc:creator><![CDATA[lhy]]></dc:creator>
		<pubDate>Mon, 15 Jul 2024 07:39:47 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[小技巧]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://blog.lhyshome.com/?p=166</guid>

					<description><![CDATA[阿里云->容器镜像服务->镜像工具->镜像加速器 安装／升级Docker客户端 推荐安装1.10.0以上版本的… <span class="read-more"><a href="https://blog.lhyshome.com/2024/07/15/166/">Read More &#187;</a></span>]]></description>
										<content:encoded><![CDATA[
<p>阿里云->容器镜像服务->镜像工具->镜像加速器</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="728" src="https://blog.lhyshome.com/wp-content/uploads/2024/07/image-1-1024x728.png" alt="" class="wp-image-167" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/07/image-1-1024x728.png 1024w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-1-300x213.png 300w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-1-768x546.png 768w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-1-500x356.png 500w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-1-800x569.png 800w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-1-660x469.png 660w, https://blog.lhyshome.com/wp-content/uploads/2024/07/image-1.png 1157w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">安装／升级Docker客户端</h2>



<p>推荐安装1.10.0以上版本的Docker客户端，参考文档<a target="_blank" rel="noreferrer noopener" href="https://yq.aliyun.com/articles/110806">docker-ce</a></p>



<h2 class="wp-block-heading">配置镜像加速器</h2>



<p>针对Docker客户端版本大于 1.10.0 的用户</p>



<p>您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器</p>



<pre class="wp-block-code"><code>sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json &lt;&lt;-'EOF'
{
  "registry-mirrors": &#91;"https://xxxxxx.mirror.aliyuncs.com"]
}
EOF

sudo systemctl daemon-reload
sudo systemctl restart docker</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.lhyshome.com/2024/07/15/166/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">166</post-id>	</item>
		<item>
		<title>docker部署es，kibana</title>
		<link>https://blog.lhyshome.com/2024/05/23/133/</link>
					<comments>https://blog.lhyshome.com/2024/05/23/133/#respond</comments>
		
		<dc:creator><![CDATA[lhy]]></dc:creator>
		<pubDate>Thu, 23 May 2024 06:24:31 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[es]]></category>
		<category><![CDATA[kibana]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://blog.lhyshome.com/?p=133</guid>

					<description><![CDATA[创建docker-net 部署es 进入es容器，安装分词器 ./bin/elasticsearch-plug… <span class="read-more"><a href="https://blog.lhyshome.com/2024/05/23/133/">Read More &#187;</a></span>]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">创建docker-net</h2>



<pre class="wp-block-code"><code>docker network create es-net</code></pre>



<h2 class="wp-block-heading">部署es</h2>



<pre class="wp-block-code"><code>docker run -d \
--restart=always \
--name es \
--network es-net \
-p 9200:9200 \
-p 9300:9300 \
--privileged=true \
-e "discovery.type=single-node" \
-e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \
elasticsearch:7.17.18</code></pre>



<p>进入es容器，安装分词器</p>



<pre class="wp-block-preformatted">./bin/elasticsearch-plugin install https://github.com/infinilabs/analysis-ik/releases/download/v7.17.18/elasticsearch-analysis-ik-7.17.18.zip</pre>



<h2 class="wp-block-heading">部署kibana</h2>



<pre class="wp-block-preformatted">docker run -d \<br>--restart=always \<br>--name kibana \<br>--network es-net \<br>-p 5601:5601 \<br>-e ELASTICSEARCH_HOSTS=http://es:9200 \<br>kibana:7.17.18</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.lhyshome.com/2024/05/23/133/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">133</post-id>	</item>
		<item>
		<title>将docker镜像推送到harbor</title>
		<link>https://blog.lhyshome.com/2024/05/16/116/</link>
					<comments>https://blog.lhyshome.com/2024/05/16/116/#respond</comments>
		
		<dc:creator><![CDATA[lhy]]></dc:creator>
		<pubDate>Thu, 16 May 2024 06:27:34 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[小技巧]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[harbor]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://blog.lhyshome.com/?p=116</guid>

					<description><![CDATA[1.将正在运行的clash容器打成镜像并推送 存在的docker容器 执行脚本 从harbor拉取制作镜像，并… <span class="read-more"><a href="https://blog.lhyshome.com/2024/05/16/116/">Read More &#187;</a></span>]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">1.将正在运行的clash容器打成镜像并推送</h2>



<h3 class="wp-block-heading">存在的docker容器</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="827" height="51" src="https://blog.lhyshome.com/wp-content/uploads/2024/12/image-15-edited.png" alt="" class="wp-image-237" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/12/image-15-edited.png 827w, https://blog.lhyshome.com/wp-content/uploads/2024/12/image-15-edited-300x19.png 300w, https://blog.lhyshome.com/wp-content/uploads/2024/12/image-15-edited-768x47.png 768w, https://blog.lhyshome.com/wp-content/uploads/2024/12/image-15-edited-500x31.png 500w, https://blog.lhyshome.com/wp-content/uploads/2024/12/image-15-edited-800x49.png 800w, https://blog.lhyshome.com/wp-content/uploads/2024/12/image-15-edited-660x41.png 660w" sizes="auto, (max-width: 827px) 100vw, 827px" /></figure>



<h3 class="wp-block-heading">执行脚本</h3>



<pre class="wp-block-code"><code># 将容器打包为镜像
docker commit clash clash:1 
# 将当前docker本地镜像（或已下载的镜像）打上tag（已下载的公共镜像从此步骤开始，打tag和上传）
docker tag clash:1 harbor_ip:harbor_port/test/clash:1
# 上传至私有镜像仓库中
docker push harbor_ip:harbor_port/test/clash:1
# 删除本地镜像
docker image rm harbor_ip:harbor_port/test/clash:1</code></pre>



<h3 class="wp-block-heading">从harbor拉取制作镜像，并运行</h3>



<pre class="wp-block-code"><code>docker pull harbor_ip:harbor_port/test/clash:1

docker run -d --name=clash -v "/home/clash:/root/.config/clash/" -p "7890:7890" -p "7891:7891" -p "9090:9090" --restart=unless-stopped harbor_ip:harbor_port/test/clash:1</code></pre>



<h2 class="wp-block-heading">2.从dockerhub上拉取镜像推送到harbor</h2>



<pre class="wp-block-code"><code>docker pull nacos/nacos-server:v2.4.3
docker tag nacos/nacos-server:v2.4.3 harbor_ip:harbor_port/test/nacos/nacos-server:v2.4.3
docker push harbor_ip:harbor_port/test/nacos/nacos-server:v2.4.3
docker image rm harbor_ip:harbor_port/test/nacos/nacos-server:v2.4.3</code></pre>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.lhyshome.com/2024/05/16/116/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">116</post-id>	</item>
		<item>
		<title>将ruoyi前后端分离版本配置Jenkins流水线</title>
		<link>https://blog.lhyshome.com/2024/05/13/84/</link>
					<comments>https://blog.lhyshome.com/2024/05/13/84/#respond</comments>
		
		<dc:creator><![CDATA[lhy]]></dc:creator>
		<pubDate>Mon, 13 May 2024 08:19:54 +0000</pubDate>
				<category><![CDATA[java]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[dockerFile]]></category>
		<category><![CDATA[jenkins]]></category>
		<category><![CDATA[k8s]]></category>
		<category><![CDATA[nginx]]></category>
		<guid isPermaLink="false">https://blog.lhyshome.com/?p=84</guid>

					<description><![CDATA[所需中间件 Jenkins+harbor+nexus+docker+k8s Jenkins执行流水线脚本命令 … <span class="read-more"><a href="https://blog.lhyshome.com/2024/05/13/84/">Read More &#187;</a></span>]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">所需中间件</h2>



<p>Jenkins+harbor+nexus+docker+k8s</p>



<p>Jenkins执行流水线脚本命令</p>



<p>harbor维护管理docker镜像</p>



<p>nexus维护私有maven依赖</p>



<p>docker创建服务各个版本的docker镜像</p>



<p>k8s部署服务镜像</p>



<h2 class="wp-block-heading">后端：</h2>



<h3 class="wp-block-heading">Jenkins流水线脚本</h3>



<pre class="wp-block-code"><code>pipeline {
    agent none
    environment {
        FLAG = 'ruoyigatewaydev'
    }
    options {
        timeout(time:25, unit: 'MINUTES')
    }
    stages {
        stage('Build Package') {
            agent {
                docker {
                    image 'maven:3.6.1-jdk-8'
                    args '-v /var/lib/jenkins/repository:/repository '
                }
            }
            steps {
                git branch: 'dev',
                        credentialsId: 'gitlab_local_pwd',
                        url: 'http://git_ip:git_port/lhy/ruoyi-gateway.git'
                sh '''
                mvn -s settings.xml -Dmaven.repo.local=/repository -B clean package -DskipTests=true
                '''
            }
        }
        stage('Build image and Push') {
            agent any
            environment {
                IMAGE_TAG = sh(returnStdout: true,script: 'echo $image_tag').trim()
            }
            steps {
                sh """	
					docker build -t harbor_ip:harbor_port/public/${FLAG}:${IMAGE_TAG} ./
					docker push harbor_ip:harbor_port/public/${FLAG}:${IMAGE_TAG}
					docker image rm harbor_ip:harbor_port/public/${FLAG}:${IMAGE_TAG}
                   """
            }
        }

        stage('Deploy') {
            agent any
            steps {
                script{
                    def remote = &#91;:]
                    remote.name = 'kube'
                    remote.host = 'k8s_ip'
                    remote.port = 22
                    remote.allowAnyHosts = true
                    //通过withCredentials调用Jenkins凭据中已保存的凭据，credentialsId需要填写，其他保持默认即可
                    withCredentials(&#91;usernamePassword(credentialsId: 'Vm_local_pwd', passwordVariable: 'password', usernameVariable: 'userName')]) {
                        remote.user = "${userName}"
                        remote.password = "${password}"
                    }
                    sshCommand remote: remote, command: """ 
                        if &#91; ! -d '/home/ruoyi/${FLAG}' ];then 
                        mkdir /home/ruoyi/${FLAG}
                        else
                        echo "文件夹已经存在"
                        fi
    				   """
                    sshPut remote: remote, from: 'k8s.yaml', into: "/home/ruoyi/${FLAG}"
                    sshCommand remote: remote, command: """ 
    					sed -i 's#${FLAG}:.*#${FLAG}:${IMAGE_TAG}#g' /home/ruoyi/${FLAG}/k8s.yaml
    					kubectl apply -f /home/ruoyi/${FLAG}/k8s.yaml
    					rm -rf /home/ruoyi/${FLAG}/k8s.yaml
    				   """
                }
            }
        }
    }
}</code></pre>



<h3 class="wp-block-heading">k8s.yml</h3>



<pre class="wp-block-code"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: ruoyigateway
  namespace: ruoyi-dev
  labels:
    app: ruoyigateway
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ruoyigateway
  template:
    metadata:
      name: ruoyigateway
      labels:
        app: ruoyigateway
    spec:
      containers:
        - name: ruoyigateway
          image: harbor_ip:harbor_port/public/ruoyigatewaydev:7.0
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: containerPort
              protocol: TCP
      restartPolicy: Always
      imagePullSecrets:
        - name: harbor-lhy

---
apiVersion: v1
kind: Service
metadata:
  name: ruoyigateway
  namespace: ruoyi-dev
spec:
  selector:
    app: ruoyigateway
  ports:
    - protocol: TCP
      port: port
      targetPort: targetPort
      nodePort: nodePort
  type: NodePort
</code></pre>



<h3 class="wp-block-heading">DockerFile</h3>



<pre class="wp-block-code"><code>FROM openjdk:8-jre<br>LABEL authors="lhyshome_pc"<br>ADD target/ruoyi-gateway.jar app.jar<br>ENTRYPOINT &#91;"java","-jar","/app.jar"]</code></pre>



<h2 class="wp-block-heading">前端</h2>



<h3 class="wp-block-heading">Jenkins流水线脚本</h3>



<pre class="wp-block-code"><code>pipeline {
    agent none
    environment {
        FLAG = 'ruoyiuidev'
    }
    options {
        timeout(time:25, unit: 'MINUTES')
    }
    stages {
        stage('npm') {
            agent {
                docker {
                    image 'node:14'
                    args '-u root:root --network=host'
                }
            }
            steps {
                git branch: 'dev',
                credentialsId: 'gitlab_local_pwd',
                url: 'http://git_ip:git_port/lhy/ruoyi-ui.git'
                sh """
                    npm install &amp;&amp; npm run build:stage
                """
            }
        }
        stage('Build image and Push') {
            agent any
            environment {
                IMAGE_TAG = sh(returnStdout: true,script: 'echo $image_tag').trim()
            }
            steps {
                sh """	
					docker build -t harbor_ip:harbor_port/public/${FLAG}:${IMAGE_TAG} ./
					docker push harbor_ip:harbor_port/public/${FLAG}:${IMAGE_TAG}
					docker image rm harbor_ip:harbor_port/public/${FLAG}:${IMAGE_TAG}
                   """
            }
        }
        stage('Deploy') {
            agent any
            steps {
                script{
                    def remote = &#91;:]
                    remote.name = 'kube'
                    remote.host = 'k8s_ip'
                    remote.port = 22
                    remote.allowAnyHosts = true
                    //通过withCredentials调用Jenkins凭据中已保存的凭据，credentialsId需要填写，其他保持默认即可
                    withCredentials(&#91;usernamePassword(credentialsId: 'Vm_local_pwd', passwordVariable: 'password', usernameVariable: 'userName')]) {
                        remote.user = "${userName}"
                        remote.password = "${password}"
                    }
                    sshCommand remote: remote, command: """ 
                        if &#91; ! -d '/home/ruoyi/${FLAG}' ];then 
                        mkdir /home/ruoyi/${FLAG}
                        else
                        echo "文件夹已经存在"
                        fi
    				   """
                    sshPut remote: remote, from: 'k8s.yaml', into: "/home/ruoyi/${FLAG}"
                    sshCommand remote: remote, command: """ 
    					sed -i 's#${FLAG}:.*#${FLAG}:${IMAGE_TAG}#g' /home/ruoyi/${FLAG}/k8s.yaml
    					kubectl apply -f /home/ruoyi/${FLAG}/k8s.yaml
    					rm -rf /home/ruoyi/${FLAG}/k8s.yaml
    				   """
                }
            }
        }
    }
}</code></pre>



<h3 class="wp-block-heading">k8s.yml</h3>



<pre class="wp-block-preformatted">apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: ruoyiui<br>  namespace: ruoyi-dev<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: ruoyiui<br>  template:<br>    metadata:<br>      labels:<br>        app: ruoyiui<br>    spec:<br>      containers:<br>        - name: ruoyiui<br>          image: harbor_ip:harbor_port/public/ruoyiuiprod:9.0<br>          ports:<br>            - containerPort: containerPort<br>---<em><br></em>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: ruoyiui<br>  namespace: ruoyi-dev<br>spec:<br>  type: LoadBalancer<br>  selector:<br>    app: ruoyiui<br>  ports:<br>    - protocol: TCP<br>      port: port<br>      targetPort: targetPort<br>      nodePort: nodePort</pre>



<h3 class="wp-block-heading">DockerFile</h3>



<pre class="wp-block-code"><code>FROM nginx:1.14.1
ADD ./dist /home
ADD ./nginx.conf /etc/nginx
EXPOSE 80
CMD &#91;"nginx", "-g", "daemon off;"]</code></pre>



<h3 class="wp-block-heading">nginx.conf</h3>



<pre class="wp-block-code"><code>worker_processes  1;<br><br>events {<br>    worker_connections  1024;<br>}<br><br>http {<br>    include       mime.types;<br>    default_type  application/octet-stream;<br>    sendfile        on;<br>    keepalive_timeout  65;<br><br>    server {<br>        listen       80;<br>        server_name  localhost;<br><br>        location / {<br>            root   /home;<br>            try_files $uri $uri/ /index.html;<br>            index  index.html index.htm;<br>        }<br><br>        # 避免actuator暴露<br>        if ($request_uri ~ "/actuator") {<br>            return 403;<br>        }<br><br>        error_page   500 502 503 504  /50x.html;<br>        location = /50x.html {<br>            root   html;<br>        }<br>    }<br>}</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.lhyshome.com/2024/05/13/84/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">84</post-id>	</item>
		<item>
		<title>docker安装nexus，搭建maven私服</title>
		<link>https://blog.lhyshome.com/2024/05/13/72/</link>
					<comments>https://blog.lhyshome.com/2024/05/13/72/#respond</comments>
		
		<dc:creator><![CDATA[lhy]]></dc:creator>
		<pubDate>Mon, 13 May 2024 07:58:21 +0000</pubDate>
				<category><![CDATA[java]]></category>
		<category><![CDATA[小技巧]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[maven]]></category>
		<guid isPermaLink="false">https://blog.lhyshome.com/?p=72</guid>

					<description><![CDATA[docker安装nexus 创建/home/nexus目录，并给其赋予777权限，完成后执行如下命令，等待启动… <span class="read-more"><a href="https://blog.lhyshome.com/2024/05/13/72/">Read More &#187;</a></span>]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">docker安装nexus</h2>



<p>创建/home/nexus目录，并给其赋予777权限，完成后执行如下命令，等待启动成功</p>



<pre class="wp-block-code"><code>docker run -d --restart always --name nexus3 -p 8081:8081 -v /home/nexus:/nexus-data sonatype/nexus3</code></pre>



<p>第一次登录用<strong>admin</strong>账号，密码在<strong>/home/nexus/admin.password</strong></p>



<h2 class="wp-block-heading">安装完成后</h2>



<h3 class="wp-block-heading">创建repository</h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="709" height="458" src="https://blog.lhyshome.com/wp-content/uploads/2024/05/image-6.png" alt="" class="wp-image-73" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/05/image-6.png 709w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-6-300x194.png 300w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-6-500x323.png 500w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-6-660x426.png 660w" sizes="auto, (max-width: 709px) 100vw, 709px" /></figure>



<p>创建如下图三个</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="674" height="134" src="https://blog.lhyshome.com/wp-content/uploads/2024/05/image-8.png" alt="" class="wp-image-75" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/05/image-8.png 674w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-8-300x60.png 300w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-8-500x99.png 500w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-8-660x131.png 660w" sizes="auto, (max-width: 674px) 100vw, 674px" /></figure>



<p>snapshots和releases创建时应设置Version policy为对应类型，Deployment policy为Allow redeploy（设置后可以上传），public设置为mixed</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="598" src="https://blog.lhyshome.com/wp-content/uploads/2024/05/image-9-1024x598.png" alt="" class="wp-image-76" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/05/image-9-1024x598.png 1024w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-9-300x175.png 300w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-9-768x449.png 768w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-9-500x292.png 500w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-9-800x467.png 800w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-9-660x385.png 660w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-9.png 1190w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>设置public时应将之前创建的snapshots和releases加入到members中去</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="732" src="https://blog.lhyshome.com/wp-content/uploads/2024/05/image-10-1024x732.png" alt="" class="wp-image-77" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/05/image-10-1024x732.png 1024w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-10-300x214.png 300w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-10-768x549.png 768w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-10-500x357.png 500w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-10-800x572.png 800w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-10-660x472.png 660w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-10.png 1103w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">创建用户及角色</h3>



<p>创建角色，并将将创建的repository权限赋予当前角色</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="697" src="https://blog.lhyshome.com/wp-content/uploads/2024/05/image-11-1024x697.png" alt="" class="wp-image-78" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/05/image-11-1024x697.png 1024w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-11-300x204.png 300w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-11-768x523.png 768w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-11-500x340.png 500w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-11-800x545.png 800w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-11-660x449.png 660w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-11.png 1150w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>创建用户，在roles中勾选刚刚创建的角色</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="706" src="https://blog.lhyshome.com/wp-content/uploads/2024/05/image-12-1024x706.png" alt="" class="wp-image-79" srcset="https://blog.lhyshome.com/wp-content/uploads/2024/05/image-12-1024x706.png 1024w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-12-300x207.png 300w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-12-768x529.png 768w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-12-500x345.png 500w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-12-800x551.png 800w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-12-660x455.png 660w, https://blog.lhyshome.com/wp-content/uploads/2024/05/image-12.png 1139w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">使用</h2>



<h3 class="wp-block-heading">maven的settings.xml配置，控制从私有仓库中的同步拉取jar</h3>



<pre class="wp-block-preformatted">&lt;server&gt;<br>    &lt;!-- id为当前用户id，后续在需要使用此用户时，对应所有id都应该用此id --&gt;<br>    &lt;id&gt;lhy-maven&lt;/id&gt;<br>    &lt;username&gt;lhy&lt;/username&gt;<br>    &lt;password&gt;password&lt;/password&gt;<br>&lt;/server&gt;<br>...........<br>                &lt;repository&gt;<br>                    &lt;id&gt;lhy-maven&lt;/id&gt;<br>                    &lt;url&gt;http://192.168.0.200:8081/repository/lhy-public/&lt;/url&gt;<br>                    &lt;releases&gt;<br>                        &lt;enabled&gt;true&lt;/enabled&gt;<br>                    &lt;/releases&gt;<br>                    &lt;snapshots&gt;<br>                        &lt;enabled&gt;true&lt;/enabled&gt;<br>                    &lt;/snapshots&gt;<br>                &lt;/repository&gt;</pre>



<h3 class="wp-block-heading">项目中的pom.xml，控制往私有仓库中deploy，不需要deploy的不需要配置</h3>



<pre class="wp-block-code"><code>&lt;distributionManagement&gt;
    &lt;repository&gt;
        &lt;!--注意这个id一定要填写我们maven的setting.xml当中配置的id--&gt;
        &lt;id&gt;lhy-maven&lt;/id&gt;
        &lt;url&gt;http://ip:port/repository/lhy-releases/&lt;/url&gt;
    &lt;/repository&gt;
    &lt;snapshotRepository&gt;
        &lt;!--注意这个id一定要填写我们maven的setting.xml当中配置的id--&gt;
        &lt;id&gt;lhy-maven&lt;/id&gt;
        &lt;url&gt;http://ip:port/repository/lhy-snapshots/&lt;/url&gt;
    &lt;/snapshotRepository&gt;
&lt;/distributionManagement&gt;</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.lhyshome.com/2024/05/13/72/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">72</post-id>	</item>
	</channel>
</rss>
