-- 네트워크를 만들어서 컨터이너를 만드는 방법 (elastic, grafana, kibana 등과 연동하기 위해서)
0. 설치후, timezone 설정법
find / -name "postgresql.conf"
/var/lib/postgresql/data/postgresql.conf 파일 열고
timezone으로 검색 . log_timezone과 timezone 모두
'Asia/Seoul' 로 변경
도커 재기동
1. 이미지 다운로드
docker pull postgres:latest
2. 실행
docker run -d -p 5432:5432 --name postgres -v postgres-root:/docker-entrypoint-initdb.d -e "POSTGRES_DB=keycloak" -e "POSTGRES_PASSWORD=password" -e "POSTGRES_USER=keycloak" postgres
로그인시 ID : keycloak,
PWD : password
3. 기타 유틸 설치
# apt-get update
#apt-get install net-tools
#apt-get install nano
#apt-get install vim
#apt-get install telnet
#apt-get install wget
#apt-get install systemd -> 이거 설치하니 python3.10 설치될때도 있고, 안될때도 있고ㅠㅠ
==> 설치 마지막즈음에 지역을 선택하라고 나옴. Asia -> Seoul 로 설정하면 시간이 맞춰짐
==> timedatectl 을 사용하기 위해서. 도커 시간이 맞추려고.
#apt-get install python3 ==> postgres 이미지를 갖고 있는 debian linux 에서는 이걸로 쉽게 설치했음.
4. HeidiSQL 클라이언트 설치
--> 아래쪽에 접속하는 이미지 파일 참조 할것
5. JDBC 드라이버 다운로드
https://jdbc.postgresql.org/download/
Download | pgJDBC
Download Binary JAR file downloads of the JDBC driver are available here and the current version with Maven Repository. Because Java is platform neutral, it is a simple process of just downloading the appropriate JAR file and dropping it into your classpat
jdbc.postgresql.org
==============================================
이하는 예전버전..
docker run -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=postgres -d ostock_dev -v init.sql:/docker-entrypoint-initdb.d/1-init.sql
docker-compose.yml
=======================================================
database:
image: postgres:latest
ports:
- "5432:5432"
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: "ostock_dev"
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/1-init.sql
- ./data.sql:/docker-entrypoint-initdb.d/2-data.sql
networks:
backend:
aliases:
- "database"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
접속하기
참고)
https://judo0179.tistory.com/96
Docker Postgresql 설치 및 셋팅하기
리눅스 컨테이너 즉 docker는 프로세스 형태로 자원을 격리하여 사용하기 때문에 컨테이너가 삭제되면 기존에 저장되었던 데이터는 사라진다. 이를 예방하기 위해서 docker volume을 사용하거나 로
judo0179.tistory.com
'DB > PostgreSQL' 카테고리의 다른 글
PostgreSQL 에서 hourly 파티션 생성및 삭제 함수 (0) | 2025.06.10 |
---|---|
샘플데이터 test_aaaaa...파티션 테스트용 (0) | 2025.06.09 |
샘플데이터 user1 (0) | 2025.06.09 |
Postgres를 더 생산적이고 안전하게 사용하는 데 도움이 되는 실용적인 패턴들 (0) | 2025.04.02 |
샘플 테이블 생성하기 (0) | 2023.11.08 |
댓글