新建Dockerfile文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#基于centos镜像
FROM centos:7
RUN mkdir -p /home/v-kun
#工作目录
WORKDIR /home/v-kun
#维护人的信息
MAINTAINER v-kun.com
#install jdk and jar包(需要确保你的centos镜像中有/usr/java/这个路径,不行就mkdir)
ADD jdk-8u291-linux-x64.tar.gz /usr/local/
#ADD dk-0.0.1-SNAPSHOT.jar /home/v-kun/
ADD nacos-server-2.3.2.tar.gz /home/v-kun/
#jdk enviroment
ENV JAVA_HOME=/usr/local/jdk1.8.0_291
ENV JRE_HOME=/usr/local/jdk1.8.0_291/jre
ENV CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
ENV PATH=$JAVA_HOME/bin:$PATH
#设置端口
#EXPOSE 8080
#执行命令
#CMD ["java","-jar","/home/v-kun/dk-0.0.1-SNAPSHOT.jar"]
CMD ["/home/v-kun/nacos/bin/startup.sh","-m","standalone"]
制作镜像
1
docker build -t vkun/nacos:2.3.2 .
命令后面有个.别漏了
<h1><a id="Dockerfile_0"></a>新建Dockerfile文件</h1>
<pre><div class="hljs"><code class="lang-shell"><span class="hljs-meta">#</span><span class="bash">基于centos镜像</span>
FROM centos:7
RUN mkdir -p /home/v-kun
<span class="hljs-meta">#</span><span class="bash">工作目录</span>
WORKDIR /home/v-kun
<span class="hljs-meta">
#</span><span class="bash">维护人的信息</span>
MAINTAINER v-kun.com
<span class="hljs-meta">
#</span><span class="bash">install jdk and jar包(需要确保你的centos镜像中有/usr/java/这个路径,不行就mkdir)</span>
ADD jdk-8u291-linux-x64.tar.gz /usr/local/
<span class="hljs-meta">#</span><span class="bash">ADD dk-0.0.1-SNAPSHOT.jar /home/v-kun/</span>
ADD nacos-server-2.3.2.tar.gz /home/v-kun/
<span class="hljs-meta">
#</span><span class="bash">jdk enviroment</span>
ENV JAVA_HOME=/usr/local/jdk1.8.0_291
ENV JRE_HOME=/usr/local/jdk1.8.0_291/jre
ENV CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
ENV PATH=$JAVA_HOME/bin:$PATH
<span class="hljs-meta">
#</span><span class="bash">设置端口</span>
<span class="hljs-meta">#</span><span class="bash">EXPOSE 8080</span>
<span class="hljs-meta">
#</span><span class="bash">执行命令</span>
<span class="hljs-meta">#</span><span class="bash">CMD [<span class="hljs-string">"java"</span>,<span class="hljs-string">"-jar"</span>,<span class="hljs-string">"/home/v-kun/dk-0.0.1-SNAPSHOT.jar"</span>]</span>
CMD ["/home/v-kun/nacos/bin/startup.sh","-m","standalone"]
</code></div></pre>
<h1><a id="_30"></a>制作镜像</h1>
<pre><div class="hljs"><code class="lang-shell">docker build -t vkun/nacos:2.3.2 .
</code></div></pre>
<blockquote>
<p>命令后面有个.别漏了</p>
</blockquote>