forked from judasn/Linux-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -398,6 +398,49 @@ docker run -d -p 58080:8080 --name javaweb huangyong/javaweb:0.1 /root/run.sh | |
http://192.168.65.132:58080/ | ||
|
||
## Dockerfile 解释 | ||
|
||
|
||
|
||
|
||
|
||
## Dockerfile 部署 | ||
|
||
- 目标:Spring Boot 应用 | ||
- CentOS 7.3 | ||
- jar 名称:skb-user-0.0.1-SNAPSHOT.jar | ||
- 打算用的宿主机端口:9096 | ||
- Dockerfile 文件和 jar 文件存放在宿主机目录:/opt/zch | ||
- Dockerfile 内容如下: | ||
|
||
``` bash | ||
FROM java:8-jre | ||
MAINTAINER skb-user zch <[email protected]> | ||
ADD skb-user-0.0.1-SNAPSHOT.jar /usr/local/skb/user/ | ||
CMD ["java", "-Xmx500m", "-jar", "/usr/local/skb/user/skb-user-0.0.1-SNAPSHOT.jar", "--spring.profiles.active=test"] | ||
EXPOSE 9096 | ||
``` | ||
|
||
- 开始构建: | ||
- `cd /opt/zch` | ||
- `docker build . --tag="skb/user:v1.0.1"` | ||
- `docker run -d -p 9096:9096 -v /usr/local/logs/:/opt/ --name="skbUser1.0.0" --net=host skb/user:v1.0.1` | ||
- 查看启动后容器列表:`docker ps` | ||
- jar 应用的日志是输出在容器的 /opt 目录下,因为我们上面用了挂载,所在在我们宿主机的 /usr/local/logs 目录下可以看到输出的日志 | ||
- 防火墙开放端口: | ||
- `firewall-cmd --zone=public --add-port=9096/tcp --permanent` | ||
- `firewall-cmd --reload` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
该文件名就叫Dockerfile,注意大小写,没有后缀,否则会报错。 | ||
|
||
|