码迷,mamicode.com
首页 > 其他好文 > 详细

docker-compose限制内存, cpu资源以及固定ip写法

时间:2020-01-09 20:33:07      阅读:2343      评论:0      收藏:0      [点我收藏+]

标签:net   image   docke   count   没有   not   ons   warning   ignore   

docker-compose v3版本写法

首先手动创建网络, 指定子网, 否则会报错

docker network create --subnet 172.88.88.0/24 devops
version: '3'

services:

 accountmgr-api:
   container_name: accountmgr-api
   image: harbor.rxtd.com:8082/rxtd/accountmgr-api:10
   ports:
     - 38080:8080
   networks:
     default:
       ipv4_address: 172.88.88.2

   deploy:
     resources:
        limits:
           cpus: '2'
           memory: 2G
        reservations:
           cpus: '0.5'
           memory: 200M
networks:
   default:
     external:
       name: devops

启动容器

docker-compose --compatibility -f gateway.yml up -d

由于做了资源限制, 并且没有使用swarm, 所以要加上--compatibility参数, 不然会报错

WARNING: Some services (web) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use docker stack deploy to deploy to a swarm.

docker-compose限制内存, cpu资源以及固定ip写法

标签:net   image   docke   count   没有   not   ons   warning   ignore   

原文地址:https://www.cnblogs.com/peitianwang/p/12173296.html

(1)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!