给flow-server添加cpu,90%,内存90%。修改上述docker-compose
时间: 2023-12-13 12:21:39 浏览: 92
您可以在docker-compose文件中使用以下语法来设置CPU和内存限制:
```
version: '3'
services:
flow-nginx:
container_name: flow-nginx
image: nginx
build:
context: .
dockerfile: nginx-dockerfile
ports:
- "80:80"
environment:
TZ: Asia/Shanghai
volumes:
- ./html/dist:/home/flow/projects/ruoyi-ui
- ./conf/nginx.conf:/etc/nginx/nginx.conf
- ./home/nginx/logs:/var/log/nginx
- ./home/nginx/conf.d:/etc/nginx/conf.d
depends_on:
- flow-server
links:
- flow-server
networks:
- base-docker_flownet
flow-server:
container_name: flow-server
build:
context: .
dockerfile: flow-dockerfile
ports:
- "8080:8089"
environment:
TZ: Asia/Shanghai
volumes:
- ./home/flow/logs:/home/flow/logs
- ./home/flow/uploadPath:/home/flow/uploadPath
- /home/flow/flow_ftp:/home/flow/flow_ftp
networks:
- base-docker_flownet
deploy:
resources:
limits:
cpus: '0.9'
memory: 90%
reservations:
memory: 90%
networks:
base-docker_flownet:
external: true
```
在上面的例子中,我们使用了deploy标签来设置资源限制。限制标签包含`cpus`和`memory`选项,用于设置CPU和内存的硬限制。在此之上,我们使用了reservations标签来设置内存的软限制。
请注意,上面的修改将容器的CPU和内存限制设置为90%。这可能会影响容器的性能,具体取决于您的应用程序的性质和需要。
阅读全文