自学内容网 自学内容网

docker-compose部署postgresql

1、docker-compose.yml文件

version: "3.9"
services:
 postgis:
  image: postgis/postgis
  container_name: postgis
  restart: always
  deploy:
      resources:
        limits:
          cpus: '1.00'
          memory: 1G
        reservations:
          cpus: '0.50'
          memory: 1G
  healthcheck:
      test: [ "CMD", "pg_isready", "-q", "-d", "postgres", "-U", "root" ]
      timeout: 45s
      interval: 10s
      retries: 10
  environment:
      POSTGRES_USER: root
      POSTGRES_PASSWORD: root
      ALLOW_IP_RANGE: 0.0.0.0/0
  ports:
    - 5432:5432
  volumes:
    - ./postgis/data:/var/lib/postgis/data  #postgis数据卷映射到本地环境
    - ./postgresql/data:/var/lib/postgresql/data #postgresql数据卷映射到本地环境

2、启动
方式一:资源限制不生效

docker-compose up

资源限制查看方式:

docker stats

方式一:

docker-compose --compatibility up -d

在这里插入图片描述
参考:在docker内设置内存与CPU限制


原文地址:https://blog.csdn.net/u013078871/article/details/136985267

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!