Substitute environment variables in NGINX config from docker-compose

Since nginx 1.19 you can now use environment variables in your configuration with docker-compose. I used the following setup: # file: docker/nginx/templates/default.conf.conf upstream api-upstream { server ${API_HOST}; } # file: docker-compose.yml services: nginx: image: nginx:1.19-alpine volumes: – “./docker/nginx/templates:/etc/nginx/templates/” environment: NGINX_ENVSUBST_TEMPLATE_SUFFIX: “.conf” API_HOST: api.example.com I’m going off script a little from the example in the documentation. … Read more

Docker 1.10 access a container by its hostname from a host machine

As answered here there is a software solution for this, called DNS Proxy Server. $ sudo ./dns-proxy-server $ docker run –rm –hostname nginx.dev nginx $ ping nginx.dev PING nginx.dev (172.17.0.4) 56(84) bytes of data. 64 bytes from 172.17.0.4 (172.17.0.4): icmp_seq=1 ttl=64 time=0.043 ms 64 bytes from 172.17.0.4 (172.17.0.4): icmp_seq=2 ttl=64 time=0.022 ms

How to directly mount NFS share/volume in container using docker compose v3

After discovering that this is massively undocumented,here’s the correct way to mount a NFS volume using stack and docker compose. The most important thing is that you need to be using version: “3.2” or higher. You will have strange and un-obvious errors if you don’t. The second issue is that volumes are not automatically updated … Read more

connecting to a docker-compose mysql container denies access but docker running same image does not

Environment variables in docker-compose.yml file should not have quotes when using array definition: db: image: mysql:5.7 ports: – “3306:3306” environment: – MYSQL_ROOT_PASSWORD=secret – MYSQL_USER=django – MYSQL_PASSWORD=secret – MYSQL_DATABASE=myAppDB If you use them in your docker-compose.yml file: db: image: mysql:5.7 ports: – “3306:3306″ environment: – MYSQL_ROOT_PASSWORD=”secret” – MYSQL_USER=”django” – MYSQL_PASSWORD=”secret” – MYSQL_DATABASE=”myAppDB” and run: $ docker-compose … Read more