Secrets as environment variables in docker-compose files

Options

I always want to make everything easier, and since I did see 1password supported secrets, I was wondering if its possible to use this with docker-compose (not hosting it, but using it as environment variables in composer files?).

It seems like its only Kubernites / K8 integration, but maybe someone have come up with a different way to do it?


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Browser:_ Not Provided

Comments

  • Hi @alekslyse, thanks for reaching out and for your interest in using secrets with 1Password!

    Based on your question there are a couple of options that could work for you; both involve the 1Password CLI (docs: https://developer.1password.com/docs/cli/).

    op inject

    # use the ref.env file (containing secret references) as input, and output the resolved secrets to the .env file
    op inject -i ref.env -o .env
    # pass the .env file with resolved secrets to docker-compose
    docker-compose —env-file .env up -d
    # remove the .env file from the disk
    rm .env
    

    op run

    # note that the resolved secrets need to be specified by variable name when passing them to docker-compose as env vars
    op run —env-file .env — docker-compose run -e SECRET1=$SECRET1 -e SECRET2=$SECRET2 web python console.py
    

    I hope that these suggestions help! Please let us know if you run into any issues.

    -- Dustin

This discussion has been closed.