Skip to content

Instantly share code, notes, and snippets.

@fike
Last active September 19, 2018 20:12
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save fike/158204255cfbc368f36fad66ccd999a7 to your computer and use it in GitHub Desktop.
Container Storage and Databases
#This is demo about databases in containers
docker volume create pgdata
docker network create postgres
docker container run -d \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=postgres \
-p 5432:5432 \
-v pgdata:/var/lib/postgresql/data \
--network postgres \
--memory 512MB \
--cpus 2 \
--sysctl kernel.sem="250 32000 100 1024" \
--sysctl kernel.shmmax=134217728 \
--ulimit rtprio=99 \
postgres
docker exec -it container_id bash
psql -U postgres
CREATE DATABASE sample;
\c sample
CREATE TABLE users (
users varchar(40),
email varchar(40),
data_reg date
);
INSERT INTO users VALUES (
'fulano', 'fulano@fulano.org', now());
psql -U postgres sample
SELECT * FROM users;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment