In development you must use a file based secret however in production this can be set to use the
docker secret create [OPTIONS] SECRET [file|-]
In production swarm / stack docker-compose file below.
| version: "3.1" | |
| services: | |
| psql: | |
| image: postgres | |
| secrets: | |
| - psql_user | |
| - psql_password | |
| environment: | |
| POSTGRES_PASSWORD_FILE: /run/secrets/psql_password | |
| POSTGRES_USER_FILE: /run/secrets/psql_user | |
| secrets: | |
| psql_user: | |
| file: ./psql_user.txt | |
| psql_password: | |
| file: ./psql_password.txt |
| QpqQcgD7dxVG |
| dbuser |