CentOS7安装部署Doctor-compose
⼀、安装doctor
#安装
yum install docker
#检验安装是否成功
[root@localhost opt]# docker --version
Docker version 1.13.1, build 7f2769b/1.13.1
#启动
systemctl start docker
⼆、安装docker compose
下载
wget github/docker/compose/releases/download/1.27.4/docker-compose-(uname−s)−(uname -m) -O /usr/local/bin/docker-compose 添加权限
sudo chmod +x /usr/local/bin/docker-compose
#检查是否安装成功 docker-compose --version
三、编写Dockerfile⽂件
1、创建 Dockerfile
FROM java:8
EXPOSE 8081
ADD vuebloght-0.0.1-SNAPSHOT.jar app.jar #打包的名称
RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java","-jar","/app.jar","--spring.profiles.active=pro"]
2、编写运⾏环境 l 红⾊的表⽰ docker容器中的名字,替换开发时测试的ip
# DataSource Config
spring:
datasource:
driver-class-name: sql.cj.jdbc.Driver
url: jdbc:mysql://mysql:3306/vueblog?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai
username: root
password: admin
mybatis-plus:
mapper-locations: classpath*:/mapper/**l
shiro-redis:
enabled: true
redis-manager:
host: redis:6379
jiaer:
jwt:
secret: f4e2e52034348f86b67cde581c0f9eb5
expire: 604800
nginx部署前端项目header: Authorization
server:
port: 8081
3、编写l⽂件
version: '3'
services:
nginx:
image: nginx:latest
ports:
- 80:80
volumes: #容器挂载本地⽂件
- /root/nginx/html:/usr/share/nginx/html
- /root/f:/etc/f
privileged: true #挂载的权限
mysql:
image: mysql:5.7.27
ports:
- 3306:3306
environment:
- MYSQL_ROOT_PASSWORD=admin #创建的密码
redis:
image: redis:latest
vueblog:
image: vueblog:latest
build: . #表⽰从本地创建
ports:
- 8081:8081
depends_on: #依赖于
- mysql
- redis
四、准备好nginx的挂载⽬录和配置
在宿主机上创建⽬录
宿主机的挂载⽬录:/root/nginx/html
挂载配置:/root/f
编写 f
#user root;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include pes;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html last; # 别忘了这个哈
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
五、修改前端Vue 中配置
axios.defaults.baseURL = "192.168.0.117:8081"
然后打包 vue项⽬ npm run build
打包springboot 项⽬ mvn clean package -st.skip=true
上传⽂件到服务器开始编排
docker-compose up -d
查看结果 docker ps
Processing math: 100%
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论