docker stack: setting environment variable from secrets

To elaborate on the original accepted answer, just change your docker-compose.yml file so that it contains this as your entrypoint: version: “3.7” services: server: image: alpine:latest secrets: – test entrypoint: [ ‘/bin/sh’, ‘-c’, ‘export TEST=$$(cat /var/run/secrets/test) ; source /entrypoint.sh’ ] secrets: test: external: true That way you don’t need any additional files!

Declare env variable which value include space for docker/docker-compose

Lets see the result running the following compose file: version: “3” services: service: image: alpine command: env env_file: env.conf env.conf: TEST_VAR1=The value TEST_VAR2=”The value2″ docker-compose up Result: service_1 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin service_1 | TEST_VAR2=”The value2″ service_1 | TEST_VAR1=The value service_1 | HOME=/root Therefore, it is legal to have spaces in the env value.

Docker MySQL connection DBeaver

For those who are running DB on different machine, you can do the following: First, from where the container is, run docker ps to get the containers details including the Container ID [root@test-001 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1b02333fb3b9 tutum/nginx “/usr/sbin/nginx” 6 weeks ago Up 7 days 0.0.0.0:80->80/tcp docker_nginx_1 … Read more

How to run docker-compose commands with ansible?

Updated answer 02/2024: docker_compose_v2 is out since community.docker v3.6.0. You can copy docker-compose.yml and run Compose such as: – name: copy Docker Compose files copy: src: files/{{ item }} dest: /somewhere/yourproject/{{ item }} loop: – docker-compose.yml – docker-compose.prod.yml # use files parameter to use multiple docker-compose.yml files # mind the _v2 suffix – name: deploy … Read more

Pass environment variables from docker-compose to container at build stage

Your docker-compose.yml should look like this: version: ‘2’ services: web: build: context: ./web args: REQUIREMENTS: “requirements_dev.txt” Your Dockerfile should define the build-argument using ARG like this: FROM python:3.5 ENV PYTHONUNBUFFERED 1 ENV APP_ROOT /usr/src/app ARG REQUIREMENTS … COPY $REQUIREMENTS $APP_ROOT/ RUN pip install -r $APP_ROOT/$REQUIREMENTS I validated this and created a minified functional demo at … Read more