Check out example codes for "docker postgres". It will help you in understanding the concepts better.

Code Example 1

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

Code Example 2

$ docker run -d --name my_postgres -v my_dbdata:/var/lib/postgresql/data -p 54320:5432 postgres:11

Learn ReactJs, React Native from akashmittal.com