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

查看原文

docker-compose v3版本

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

docker network create --subnet 172.88.88.0/24 devops
gateway.yml
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.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值