I am unable to created a database named volume

[root@local dockerfile-sample-2]# docker container run -d --name psql -v psql:/var/lib/postgresql/data postgres:9.6
4d906eb3cdf5c4f8c578396eb6d908964a0c19c7e2bc5c9e5fff381b2cddc7ba

When i list it its not showing
[root@local dockerfile-sample-2]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
32c1baa6bb5b nginx “nginx -g 'daemon of…” 37 minutes ago Up 37 minutes 0.0.0.0:8080->80/tcp nginxc
ce1581026ada mysql “docker-entrypoint.s…” 2 hours ago Up 2 hours 3306/tcp, 33060/tcp mysql
It exited as soon as it started
[root@local dockerfile-sample-2]# docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d906eb3cdf5 postgres:9.6 “docker-entrypoint.s…” 13 seconds ago Exited (1) 11 seconds ago psql

Is it mandatory to define password?

I am just learning docker so this could be a silly question although but need help

start a postgres instance

$ docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres

There is a reason why POSTGRES_PASSWORD is shown in the “How to use this image” section in the Dockerhub description… Add it your command somehere between docker run and the image name and you should be good.

1 Like