본문 바로가기
Linux

실습4

by newlibra 2024. 8. 24.

 

$> docker image pull postgres
$> docker image ls
$> docker container run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
$> docker container ls 
$> docker container exec -it 03ab11220657 /bin/bash 
#> psql -U postgres 
postgres#> CREATE USER user01 PASSWORD '1234' SUPERUSER; 
postgres#> CREATE DATABASE test01 OWNER user01; 
postgres#> \c test01 user01 
test01#> CREATE TABLE table01(
           id INTEGER PRIMARY KEY,
           name VARCHAR(20)
           );
test01#> \dt 
test01#> SELECT * FROM table01; 
test01#> INSERT INTO table01 (id, name) values (1, 'shin');
test01#> SELECT * FROM table01; 
test01#> \q
#> exit 

$> docker container ls 
$> docker container stop 03ab11220657 
$> docker container ls 
$> docker container ls -a 
$> docker container start 03ab11220657 
$> docker container ls 
$> docker container exec -it 03ab11220657 /bin/bash 
#> psql -U postgres 
postgres#> \c test01 user01 
test01#> \dt 
test01#> SELECT * FROM table01; 
test01#> \q 
#> exit 

$> docker container ls 
$> docker container stop 03ab11220657
$> docker container ls -a 
$> docker container rm 03ab11220657
$> docker container ls -a 
$> docker container run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
$> docker container ls 
$> docker container exec -it ba02da9d2eb2 /bin/bash 
#> psql -U postgres 
postgres#> \c test01 user01 
postgres#> \q
#> exit 
$> docker container stop ba02da9d2eb2
$> docker container ls


 

'Linux' 카테고리의 다른 글

fedora linux system  (0) 2024.11.24
ubuntu24.10  (0) 2024.11.03
kubernetes  (0) 2024.08.18
docker & kubernetes  (0) 2024.08.18
ubuntu vm setting  (0) 2024.08.17