ECS jwilder/nginx-proxy fails to start


Does anyone know how to set up the jwilder/nginx-proxy run properties in the Task Definition?

I am using dynamic ports for Blue Green deployment and since the ports are dynamic, the default.conf proxy routing is not finding the upstream paths. Therefore, I started to use the jwilder/nginx-proxy so the nginx can update the path almost instantaneously. The issue that I am having is that when i try to start up the jwilder nginx, it fails. Below is what i can see from the logs. I think that one issue is that when i identified the volume (-v /var/run/docker.sock:/tmp/docker.sock:ro) it is not finding it. I tried as a volume from and mount.

7/9/2023, 1:22:19 AM EDT Generating DSA parameters, 4096 bit long prime nginx-proxy

7/9/2023, 1:22:19 AM EDT WARNING: /etc/nginx/dhparam/dhparam.pem was not found. A pre-generated dhparam.pem will be used for now while a new one nginx-proxy

7/9/2023, 1:22:19 AM EDT is being generated in the background. Once the new dhparam.pem is in place, nginx will be reloaded. nginx-proxy

7/9/2023, 1:22:19 AM EDT ERROR: you need to share your Docker host socket with a volume at /tmp/docker.sock nginx-proxy

7/9/2023, 1:22:19 AM EDT Typically you should run your nginxproxy/nginx-proxy with: -v /var/run/docker.sock:/tmp/docker.sock:ro nginx-proxy 7/9/2023, 1:22:19 AM EDT See the documentation at nginx-proxy

Thank you.

gefragt vor einem Jahr385 Aufrufe
2 Antworten


To set up the jwilder/nginx-proxy run properties in the Task Definition on AWS using dynamic ports for Blue Green deployment, you can follow these steps:

  1. Create a Task Definition for your application on AWS ECS (Elastic Container Service).
  2. In the Task Definition, specify the container image for jwilder/nginx-proxy.
  3. Configure the container port mapping to use dynamic ports. This can be done by leaving the "Container Port" field blank or setting it to 0.
  4. In the "Environment" section of the Task Definition, define environment variables for the upstream paths you want to route to. For example, you can set environment variables like UPSTREAM_APP1=http://app1:8000 and UPSTREAM_APP2=http://app2:8000, where app1 and app2 are the service names of your blue and green applications.
  5. Save the Task Definition.

Now, when you launch a task using this Task Definition, AWS ECS will automatically assign a dynamic port to the jwilder/nginx-proxy container. To ensure that the proxy routing works correctly, you need to update the default.conf file used by the nginx-proxy container.

To achieve this, you can create a custom default.conf file and mount it as a volume in the nginx-proxy container. In this custom default.conf file, you can use environment variables to dynamically set the upstream paths. For example:

location /app1 {
proxy_pass $UPSTREAM_APP1;

location /app2 {
proxy_pass $UPSTREAM_APP2;

By using environment variables in the default.conf file, the proxy routing will correctly find the upstream paths based on the dynamic port assigned to the nginx-proxy container.

I hope this helps!

profile picture
beantwortet vor einem Jahr
  • Pedro, thank you for your answer. However, I believe that I have that section down pat. The issue that I seem to be having now is with the volume portion of the run command (example from jwilder git is: docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy). I am not sure where i would break down that command in the task definition. I tried Mount and VolumeFrom and it did not work.


Latest error is:

Status reason	CannotCreateContainerError: Error response from daemon: invalid volume specification: 'jwilder:/var/run/docker.sock:/tmp/docker.sock:ro'
links	["value"]
Host name	nginx-proxy
Read only root file system	false

beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen