Last active
September 19, 2018 20:12
-
-
Save fike/158204255cfbc368f36fad66ccd999a7 to your computer and use it in GitHub Desktop.
Container Storage and Databases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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', '[email protected]', 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