• [DevOps] Set up and run a PostgreSQL instance locally with Docker Compose


    When we need to spin up a database instance for our new project, installing the database management system directly on our local machine is almost always a bad idea. Luckily, Docker is here to help us practically reduce the complexity of dealing with "missing dependencies" and weird error messages down to zero.

    In this lesson, we will learn how to get a PostgreSQL instance running locally with Docker Compose, so we can work on the database integration of our project and test things out with ease. To follow this lesson, you will need to have Docker pre-installed.

    docker-compose.yml:

    version: "3.8"
    services:
      db:
        image: "postgres:12"
        ports:
          - "54320:5432"
        volumes:
          - ./pgdata:/var/lib/postgresql/data
        environment:
          - POSTGRES_USER=alice
          - POSTGRES_PASSWORD=wonderland
          - POSTGRES_DB=myawesomedb
    # Up and Running
    
    docker-compose -d
    
    # Check Whether contain is running
    
    docker-compose ps
    
    # enter the shell
    
    docker-compose run db bash
    
    ## Verify db exist
    
    poql --host=db --username=alice --dbname=myawesomedb
    
    ## Esc the db
    
    Ctrl + d twice
    
    # Off
    
    docker-compose down
  • 相关阅读:
    LeetCode之Z字形变换
    统计文本中字母的频次(不区分大小写)
    凯撒密码实现
    DES 实现
    cmake 学习
    ubuntu18 ssh服务器拒绝连了密码
    Ubuntu13 安装vim
    面向对象和面向过程的理解
    图像变换
    基于关键帧的RGB-D视觉惯性里程计
  • 原文地址:https://www.cnblogs.com/Answer1215/p/12912149.html
Copyright © 2020-2023  润新知