zoukankan      html  css  js  c++  java
  • ubuntu@center-kitchen:/data/postsql-redis$ sudo docker exec -it 1676ca9b2eb9 psql -U postgres -d postgres psql: FATAL: role "postgres" does not exist

    使用docker-compose.yml创建postgresSQL,登录psql容器时提示缺少postgres角色:

    ubuntu@center-kitchen:/data/postsql-redis$ sudo docker exec -it 1676ca9b2eb9 psql -U postgres -d postgres

    psql: FATAL:  role "postgres" does not exist

    排查了很久,查看了官方文档,找到了问题,缺个参数:privileged: true(红色字体所示),贴上我的yml文件:

    version: '2.3'

    networks:

        ic_net:

          name: ic_net

          ipam:

            driver: default

            config:

              - subnet: "172.20.0.0/24"

    services:

      redis:

        image: redis:4

        restart: always

        container_name: pigfarm_redis

        ports:

          - 6379:6379

        logging:

          driver: "json-file"

          options:

            max-size: "100m"

        networks:

          - ic_net

     

      postgres:

        image: postgres:9.6

        restart: always

        container_name: pigfarm_postgres

        ports:

          - 5432:5432

        privileged: true

        environment:

          POSTGRES_PASSWORD: postgres

          PGDATA: /var/lib/postgresql/data/pgdata

        volumes:

          - ./pg_data/data:/var/lib/postgresql/data/pgdata

        logging:

          driver: "json-file"

        networks:

          - ic_net

    ubuntu@center-kitchen:/data/postsql-redis$ sudo docker-compose down

    ubuntu@center-kitchen:/data/postsql-redis$ sudo docker-compose up -d

    重启后,登录验证,成功进入数据库,如下所示:

    ubuntu@center-kitchen:/data/postsql-redis$ sudo docker exec -it bd04bb35f624 psql -U postgres -d postgres

    psql (9.6.17)

    Type "help" for help.

     postgres=# 

    结束。

     

  • 相关阅读:
    关于windows客户端网络编程 WSAAsyncSelect函数
    阻塞模式和非阻塞模式
    SRP6协议分析
    普通二叉树转换成二叉查找树方法
    使用openssl库进行开发
    类型转化,网络开发中常见的类型转化
    到底还能够称多久
    权限子系统小结
    使用ASP.NET AJAX开发服务器端事件通知器
    通用权限相关文档的下载
  • 原文地址:https://www.cnblogs.com/liusingbon/p/12790106.html
Copyright © 2011-2022 走看看