AKAI TSUKI

System development or Technical something

start postgres

try to start postgres by docker.

[root@localhost ~]# docker pull postgres
Using default tag: latest
latest: Pulling from library/postgres

75a822cd7888: Pull complete
68f8c57d4ec8: Pull complete
1ee19503c02a: Pull complete
ea8f451ca276: Pull complete
bce67042ed9c: Pull complete
eb0990abb35a: Pull complete
af6ba638869d: Pull complete
e8d456ed70c7: Pull complete
1d9946f84913: Pull complete
aaaf404de7ad: Pull complete
6cd7c84ea195: Pull complete
Digest: sha256:855b55b060bfa63cb39bfee0fe4ec6f40037e9f85f8a7eec24bc8e59ec1a8345
Status: Downloaded newer image for postgres:latest
[root@localhost ~]#
[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              7                   67591570dd29        3 weeks ago         191.8 MB
centos              latest              67591570dd29        3 weeks ago         191.8 MB
postgres            latest              0e24dd8079dc        3 weeks ago         264.8 MB
hello-world         latest              c54a2cc56cbb        6 months ago        1.848 kB
[root@localhost ~]#
[root@localhost ~]# docker run -d --name postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 postgres
97cae9fa17066121adb77694f96bfd142d674328c8220669f1a774fc0685b320
[root@localhost ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
97cae9fa1706        postgres            "/docker-entrypoint.s"   4 seconds ago       Up 2 seconds        0.0.0.0:5432->5432/tcp   postgres
[root@localhost ~]# docker run -it --rm --link postgres:postgres postgres psql -h postgres -U postgres
Password for user postgres:
psql (9.6.1)
Type "help" for help.

postgres=# \h