Recently, started building docker image for my application. Application uses few secret keys which are used to connect other microservices. I read about the docker secrets with swarm mode which hold the application secrets and I made changes in application to accepts the docker secrets. I created secrets using command..
printf "my-secrets12345" | docker secret create adminpassword
Then I deployed service using following command with docker-compose file..
version: '3.1'
services:
testService:
secrets:
- adminpassword
image: "test-docker-secret:latest"
#container_name: test-docker-secret
ports:
- "8080:8080"
environment:
SPRING_PROFILES_ACTIVE: dev
SERVER_SSL_ENABLED: "true"
volumes:
- /home/tridev/pathtocerts/:/tmp/certificates/
secrets:
adminpassword:
external: true
and the deployed
docker stack deploy --compose-file=test-stack-compose.yml testservice
And all after this my service started and working as expected, Here I thought my secrets are not visible to anyone in plain text and secure now. But when I went inside the container and browsed the directory /run/secrets/
, here I can see all my secrets in plain text. Also I can see my secrets from host machine by using
docker container exec $(docker ps --filter name=testservice -q) cat /run/secrets/adminpassword
Here, I see If anyone get access to my container or service he can see secrets and access data from other services. Here It feels like docker secrets are illusionist and secrets are visible.
Is there any other way with docker where I can store secret keys securely?