Last active
April 7, 2024 04:29
-
-
Save ronaldb/d4b3d3327a5f80bfd12d748ca0ae91ae to your computer and use it in GitHub Desktop.
Docker - Use secrets in a single node docker environment and mysql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.6" | |
services: | |
my_sql: | |
image: mysql:5.7 | |
volumes: | |
- ./data:/var/lib/mysql | |
secrets: | |
- my_secret | |
environment: | |
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/my_secret | |
MYSQL_DATABASE: todos | |
nodejs: | |
image: node:8 | |
secrets: | |
- my_secret | |
environment: | |
MYSQL_PASSWORD_FILE: /run/secrets/my_secret | |
secrets: | |
my_secret: | |
file: ./super_duper_secret.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
passwd = fs.readFileSync(process.env.MYSQL_PASSWORD_FILE, 'utf8').trim(); | |
console.log(passwd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting below error while building.
ERROR: for secrets-poc_my_sql_1 Cannot create container for service my_sql: invalid mount config for type "bind": stat /home/user1/secrets-poc/super_duper_secret.txt: permission denied
ERROR: for my_sql Cannot create container for service my_sql: invalid mount config for type "bind": stat /home/user1/secrets-poc/super_duper_secret.txt: permission denied
ERROR: Encountered errors while bringing up the project.
Anything I am missing here?