community.docker icon indicating copy to clipboard operation
community.docker copied to clipboard

Pass envs to docker-compose

Open mihalt opened this issue 1 month ago • 1 comments

I am tryting to pass envs to use it like

services:
  rabbit:
    restart: always
    image: rabbitmq
    volumes:
      - ${DATABASES_FOLDER}/rabbit:/var/lib/rabbitmq

I did standard environment attribute, but it doesn't work for me. They don't pass to my docker compose file that I use in ansible like

  environment:
    DATABASES_FOLDER: /
  tasks:
    - ansible.builtin.copy:
        src: ./docker-compose.yml
        dest: .
    - community.docker.docker_compose_v2:
        project_src: "."

I haven't found anything except env_files attribute in your docs. I think the passing environments like docker compose run -e VAR or something like this should help.

mihalt avatar May 09 '24 13:05 mihalt