【技術メモ】MacにDockerでPostgresを立てて繋ぐ
MacにDockerでPostgresを立てて繋ぐ
概要
とりあえずDB接続系の検証用に、サクッとローカルMacにPostgresを立てたい時。
詳細
### DockerHubのイメージでコンテナ立てる $ docker run -d --name postgres-container -e POSTGRES_PASSWORD=password -p 5432:5432 postgres ### 繋ぐ $ psql -h localhost -p 5432 -U postgres
### 何かSELECTしたいのでDBを作るメモ create table table1 ( id serial not null, name varchar(20), primary key (id) ); insert into table1 values ( default, 'tom' ); insert into table1 values ( default, 'joji' ); insert into table1 values ( default, 'andy' ); insert into table1 values ( default, 'bob' ); insert into table1 values ( default, 'sam' );
以上。