PostgreSQL environment construction with Docker (from setup to just before development)

How to proceed

--A style in which you can hit commands and proceed to the process immediately before development, and adjust detailed settings by looking at the reference site ――It feels like you're pushing forward with the aim of creating an environment where you can move. --Since we are doing it as part of building the environment to run django, there are some descriptions other than postgreSQL and the description for running postgreSQL without a password.

Premise

--Docker installation is complete ――I don't remember having a hard time, so I think I put it in quickly by looking at the official page or reference page. --For reference, it is a link to Official page --Running in mac environment (10.14.6)

procedure

Preparing docker files

nothing special.

Preparing docker-compose file

docker-compose.yml


version: '3'

services:
  db:
    image: postgres
    environment:
        POSTGRES_HOST_AUTH_METHOD: 'trust'
    volumes:
      - ./database:/var/lib/postgresql/data

Various settings of postgresql

To check the operation on docker, start PostgreSQL on Docker and make bash running in advance. Execute the following command in the terminal.

#Start the container (""-Add "d" to run in the background)
docker-compose up -d
#Check the container name
docker ps
#Connect to container
docker exec -it {postgreSQL container name} bash
#Login to postgreSQL
psql -U postgres

--User created

--Create user
create role {role name} with login password '{password}';
--Confirmation of creation result
\du

It is assumed that roles will be assigned separately, but this article will not cover them. Please refer to this page and create it if necessary. https://www.dbonline.jp/postgresql/role/index2.html#section1 https://www.dbonline.jp/postgresql/role/index3.html

--Create database

--Creating a database
create database {database name};
--View database list
\l

--Schema creation

--Creating a schema
CREATE SCHEMA {schema name};
create schema anpi;

--Schema list
\dn

--Create table

--Creating a table
create table {schema name}.{table name};

--Table list
\dt {schema name}.*;

Reference site

Recommended Posts

PostgreSQL environment construction with Docker (from setup to just before development)
Laravel development environment construction with Docker (Mac)
Wordpress local environment construction & development procedure with Docker
[Docker] Rails 5.2 environment construction with docker
React environment construction with Docker
JavaFX application development with IntelliJ IDEA and Gradle ~ From environment construction to sample code ~
I made a development environment with rails6 + docker + postgreSQL + Materialize.
Rails application development environment construction with Docker [Docker, Rails, Puma, Nginx, MySQL]
How to build Rails, Postgres, ElasticSearch development environment with Docker
I tried to create a padrino development environment with Docker
Node.js environment construction with Docker Compose
Environment construction with Docker for beginners
[Environment construction with Docker] Rails 6 & MySQL 8
Update MySQL from 5.7 to 8.0 with Docker
Ruby on Rails --From environment construction to simple application development on WSL2
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
Super beginner builds Rails6 + Postgresql environment with Docker to the end
How to install Pry after building Rails development environment with Docker
GPU environment construction with Docker [October 2020 version]
Rails environment construction with Docker (personal apocalypse)
Building Rails 6 and PostgreSQL environment with Docker
Build a PureScript development environment with Docker
Environment construction with Docker (Ubuntu20.04) + Laravel + nginx
Create a MySQL environment with Docker from 0-> 1
Create Spring Boot-gradle-mysql development environment with Docker
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Laravel + MySQL + phpMyadmin environment construction with Docker
Build a Wordpress development environment with Docker
Lightweight PHP 7.4 development environment created with Docker
Environment construction summary with rvm and postgresql
How to build Rails 6 environment with Docker
How to execute with commands of normal development language in Docker development environment
I tried to build a Firebase application development environment with Docker in 2020
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Docker environment construction
Spring Boot environment construction with Docker (January 2021 version)
Build a development environment for Docker + Rails6 + Postgresql
[Jakarta EE 8 application development with Gradle] 1. Environment construction
How to link Rails6 Vue (from environment construction)
Environment construction command memo with Docker on AWS
Rails6 [API mode] + MySQL5.7 environment construction with Docker
Setting to exit from Docker container with VScode
A reminder of Docker and development environment construction
React + Django + Nginx + MySQL environment construction with Docker
[Rails] How to build an environment with Docker
[First team development ②] Build an environment with Docker
Create a Spring Boot development environment with docker
Temporarily move Docker environment from Mac to AWS
Build a development environment to create Ruby on Jets + React apps with Docker
Introduction to Slay the Spire Mod Development (2) Development Environment Construction
BEAR application Docker development environment construction example (docker-sync, Mutagen)
How to build docker environment with Gradle for intelliJ
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
Rails Docker environment construction
[Docker environment] How to deal with ActiveSupport :: MessageEncryptor :: InvalidMessage
[First team development ③] Share the development environment created with Docker
Java development for beginners to start from 1-Vol.1-eclipse setup
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
[Note] Create a java environment from scratch with docker