The [Docker Postgres samples library](https://docs.docker.com/samples/library/postgres/#start-a-postgres-instance) provides examples of starting a postgreSQL instance via `docker run` or using `docker-compose` file, both are shown below respectively. 

The `docker run` call is exposing the password in the command and the `docker-compose` file exposes the password which could be viewed on Github. I've learnt to never expose credentials in this way and always retrieve from the environment. Is there a right way to dockerize postgreSQL with security in mind? Or is this secure and my understanding is incorrect? 

`docker run` example:

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

```

`docker-compose` example:

```
version: '3.1' 
services:
    db:
        image: postgres
        restart: always
        environment:
            POSTGRES_PASSWORD: example

```