Docker Community Forums

Share and learn in the Docker community.

Docker secrets in docker-compose.yml

swarm
docker

(Sirchristian) #1

I have encountered problems with usage of docker secrets in docker-compose. Here is my yml:

version: '3.6'

secrets:
  aws_bucket_name:
    file: ./secrets/aws_bucket_name.txt

services:
  my-service-name:
    image: my-service-name
    secrets:
      - aws_bucket_name
    build:
      context: .
      dockerfile: Dockerfile-dev
    volumes:
      - ./:/my-service-name
    ports:
      - 3000:3000
      - 9229:9229
    environment:
      AUTH_BASICAUTH_ENABLED: "true"
      NODE_ENV: "development"

So, If I understand it correctly I should have aws_bucket_name.txt in my project in secrets folder, that is truth.

I’m trying to load data from this file through aws_bucket_name.

When I build docker-compose I get this error:

ERROR: for iothubtelemetryadapter_my-service-name_1 Cannot create container for service my-service-name: invalid mount config for type "bind": invalid mount path: 'C:/Users/anton.smatanik/Documents/project_name/secrets/aws_bucket_name.txt' mount path must be absolute

Here is my project structure:

structure