Docker-letsencrypt-nginx-proxy-companion: Exit Code 1 - AWS ECS

Created on 1 Feb 2018  路  12Comments  路  Source: nginx-proxy/docker-letsencrypt-nginx-proxy-companion

Hello there.
I'm running jwilder/nginx + docker-letsencrypt-nginx-proxy-companion in the same task, but for some reason the companion just start and finish instantly, giving "Exit Code 1";

AWS Task Definition

 {
  "executionRoleArn": null,
  "containerDefinitions": [
    {
      "dnsSearchDomains": null,
      "logConfiguration": null,
      "entryPoint": null,
      "portMappings": [
        {
          "hostPort": 80,
          "protocol": "tcp",
          "containerPort": 80
        },
        {
          "hostPort": 443,
          "protocol": "tcp",
          "containerPort": 443
        }
      ],
      "command": null,
      "linuxParameters": null,
      "cpu": 0,
      "environment": [],
      "ulimits": null,
      "dnsServers": null,
      "mountPoints": [
        {
          "readOnly": true,
          "containerPath": "/etc/nginx/certs",
          "sourceVolume": "home-ec2-user-certs"
        },
        {
          "readOnly": null,
          "containerPath": "/etc/nginx/vhosts.d",
          "sourceVolume": "etc-nginx-vhosts-d"
        },
        {
          "readOnly": null,
          "containerPath": "/usr/share/nginx/html",
          "sourceVolume": "usr-share-nginx-html"
        },
        {
          "readOnly": true,
          "containerPath": "/tmp/docker.sock",
          "sourceVolume": "var-run-docker-sock"
        }
      ],
      "workingDirectory": null,
      "dockerSecurityOptions": null,
      "memory": 128,
      "memoryReservation": null,
      "volumesFrom": [],
      "image": "jwilder/nginx-proxy",
      "disableNetworking": null,
      "essential": true,
      "links": null,
      "hostname": null,
      "extraHosts": null,
      "user": null,
      "readonlyRootFilesystem": null,
      "dockerLabels": {
        "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy": ""
      },
      "privileged": null,
      "name": "nginx"
    },
    {
      "dnsSearchDomains": null,
      "logConfiguration": null,
      "entryPoint": null,
      "portMappings": [],
      "command": null,
      "linuxParameters": null,
      "cpu": 0,
      "environment": [],
      "ulimits": null,
      "dnsServers": null,
      "mountPoints": [
        {
          "readOnly": null,
          "containerPath": "/etc/nginx/certs",
          "sourceVolume": "home-ec2-user-certs"
        },
        {
          "readOnly": true,
          "containerPath": "/var/run/docker.sock",
          "sourceVolume": "var-run-docker-sock"
        }
      ],
      "workingDirectory": null,
      "dockerSecurityOptions": null,
      "memory": 128,
      "memoryReservation": null,
      "volumesFrom": [
        {
          "sourceContainer": "nginx",
          "readOnly": null
        }
      ],
      "image": "jrcs/letsencrypt-nginx-proxy-companion",
      "disableNetworking": null,
      "essential": false,
      "links": null,
      "hostname": null,
      "extraHosts": null,
      "user": null,
      "readonlyRootFilesystem": null,
      "dockerLabels": null,
      "privileged": null,
      "name": "jrcs-letsencrypt-nginx-proxy-companion"
    }
  ],
  "placementConstraints": [],
  "memory": "128",
  "taskRoleArn": null,
  "compatibilities": [
    "EC2"
  ],
  "taskDefinitionArn": "arn:aws:ecs:us-west-2:3213368336:task-definition/nginx:16",
  "family": "nginx",
  "requiresAttributes": [
    {
      "targetId": null,
      "targetType": null,
      "value": null,
      "name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
    }
  ],
  "requiresCompatibilities": null,
  "networkMode": null,
  "cpu": null,
  "revision": 16,
  "status": "ACTIVE",
  "volumes": [
    {
      "name": "home-ec2-user-certs",
      "host": {
        "sourcePath": "/home/ec2-user/certs"
      }
    },
    {
      "name": "etc-nginx-vhosts-d",
      "host": {
        "sourcePath": "/etc/nginx/vhosts.d"
      }
    },
    {
      "name": "usr-share-nginx-html",
      "host": {
        "sourcePath": "/usr/share/nginx/html"
      }
    },
    {
      "name": "var-run-docker-sock",
      "host": {
        "sourcePath": "/var/run/docker.sock"
      }
    }
  ]
} 

Docker Inspect

[
    {
        "Id": "2c92a903341b877a27763f8617f8bae388896040810730c80f29bd1d990d5364",
        "Created": "2018-02-01T16:24:47.521812721Z",
        "Path": "/bin/bash",
        "Args": [
            "/app/entrypoint.sh",
            "/bin/bash",
            "/app/start.sh"
        ],
        "State": {
            "Status": "exited",
            "Running": false,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 0,
            "ExitCode": 1,
            "Error": "",
            "StartedAt": "2018-02-01T16:24:48.186350928Z",
            "FinishedAt": "2018-02-01T16:24:48.303503379Z"
        },
        "Image": "sha256:aca3dd54e19e1c995554c9e391ebc36f0a278422296c97256e785bd30bd1c995",
        "ResolvConfPath": "/var/lib/docker/containers/2c92a903341b877a27763f8617f8bae388896040810730c80f29bd1d990d5364/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/2c92a903341b877a27763f8617f8bae388896040810730c80f29bd1d990d5364/hostname",
        "HostsPath": "/var/lib/docker/containers/2c92a903341b877a27763f8617f8bae388896040810730c80f29bd1d990d5364/hosts",
        "LogPath": "/var/lib/docker/containers/2c92a903341b877a27763f8617f8bae388896040810730c80f29bd1d990d5364/2c92a903341b877a27763f8617f8bae388896040810730c80f29bd1d990d5364-json.log",
        "Name": "/ecs-nginx-16-jrcs-letsencrypt-nginx-proxy-companion-dad5cfc68bcb9d80cc01",
        "RestartCount": 0,
        "Driver": "devicemapper",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/home/ec2-user/certs:/etc/nginx/certs",
                "/var/run/docker.sock:/var/run/docker.sock:ro"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": null,
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [
                "ecs-nginx-16-nginx-92f0c197b8d3d6a6b001"
            ],
            "CapAdd": null,
            "CapDrop": null,
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 2,
            "Memory": 134217728,
            "NanoCpus": 0,
            "CgroupParent": "/ecs/0ee0097a-d264-4204-847d-ccf3a37e69cd",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 268435456,
            "MemorySwappiness": 0,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": [
                {
                    "Name": "nofile",
                    "Hard": 4096,
                    "Soft": 1024
                }
            ],
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0
        },
        "GraphDriver": {
            "Data": {
                "DeviceId": "30",
                "DeviceName": "docker-202:1-263246-9d5baaf4b96dd02683befa4d214c2a08861494198867b618e66549b2a1776252",
                "DeviceSize": "10737418240"
            },
            "Name": "devicemapper"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/var/run/docker.sock",
                "Destination": "/var/run/docker.sock",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/etc/nginx/vhosts.d",
                "Destination": "/etc/nginx/vhosts.d",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/usr/share/nginx/html",
                "Destination": "/usr/share/nginx/html",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/var/run/docker.sock",
                "Destination": "/tmp/docker.sock",
                "Mode": "",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Type": "volume",
                "Name": "91f6a2d456a46a8f353a43c3714219dd04a583f1e367d1d68d3235eeace99418",
                "Source": "/var/lib/docker/volumes/91f6a2d456a46a8f353a43c3714219dd04a583f1e367d1d68d3235eeace99418/_data",
                "Destination": "/etc/nginx/dhparam",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "bind",
                "Source": "/home/ec2-user/certs",
                "Destination": "/etc/nginx/certs",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "2c92a903341b",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "DEBUG=false",
                "DOCKER_GEN_VERSION=0.7.3",
                "DOCKER_HOST=unix:///var/run/docker.sock"
            ],
            "Cmd": [
                "/bin/bash",
                "/app/start.sh"
            ],
            "ArgsEscaped": true,
            "Image": "jrcs/letsencrypt-nginx-proxy-companion",
            "Volumes": null,
            "WorkingDir": "/app",
            "Entrypoint": [
                "/bin/bash",
                "/app/entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "com.amazonaws.ecs.cluster": "cluster-teste",
                "com.amazonaws.ecs.container-name": "jrcs-letsencrypt-nginx-proxy-companion",
                "com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-west-232386368363task/0ee0097a-d264-4204-847d-ccf3a37e69cd",
                "com.amazonaws.ecs.task-definition-family": "nginx",
                "com.amazonaws.ecs.task-definition-version": "16",
                "maintainer": "Yves Blusseau <[email protected]> (@blusseau)"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "be5ceee55553ad5629fa12c3a3ab7c46b09402011f6ed4b8d850541925fdd260",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/be5ceee55553",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "773a2adb07a0f7553e062b2eb9ded6ee10a7eace022e57c47d654bef8cce0737",
                    "EndpointID": "",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "",
                    "DriverOpts": null
                }
            }
        }
    }
]

Sorry about my ignorance, but, the container was not to be running in the background?

Amazon ECS

Most helpful comment

I was having the same issue. Turned out to be just a few typos.

Here is my working version:

{
  "family": "nginx",
  "taskRoleArn": "",
  "executionRoleArn": "",
  "networkMode": "none",
  "containerDefinitions": [
    {
      "dnsSearchDomains": null,
      "logConfiguration": null,
      "entryPoint": null,
      "portMappings": [
        {
          "hostPort": 80,
          "protocol": "tcp",
          "containerPort": 80
        },
        {
          "hostPort": 443,
          "protocol": "tcp",
          "containerPort": 443
        }
      ],
      "command": null,
      "linuxParameters": null,
      "cpu": 0,
      "environment": [
        {
          "name": "DOCKER_PROVIDER",
          "value": "ecs"
        },
        {
          "name": "NGINX_DOCKER_GEN_CONTAINER",
          "value": "nginx-gen"
        },
        {
          "name": "NGINX_PROXY_CONTAINER",
          "value": "nginx"
        }
      ],
      "ulimits": null,
      "dnsServers": null,
      "mountPoints": [
        {
          "readOnly": false,
          "containerPath": "/etc/nginx/certs",
          "sourceVolume": "certs"
        },
        {
          "readOnly": true,
          "containerPath": "/tmp/docker.sock",
          "sourceVolume": "docker"
        },
        {
          "readOnly": false,
          "containerPath": "/usr/share/nginx/html",
          "sourceVolume": "usr-share-nginx-html"
        },
        {
          "readOnly": false,
          "containerPath": "/etc/nginx/vhost.d",
          "sourceVolume": "usr-share-nginx-vhost"
        }
      ],
      "workingDirectory": null,
      "dockerSecurityOptions": null,
      "memory": 128,
      "memoryReservation": null,
      "volumesFrom": [],
      "image": "jwilder/nginx-proxy",
      "disableNetworking": null,
      "essential": true,
      "links": null,
      "hostname": null,
      "extraHosts": null,
      "user": null,
      "readonlyRootFilesystem": null,
      "dockerLabels": {
        "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy": ""
      },
      "privileged": null,
      "name": "nginx"
    },
     {
      "dnsSearchDomains": null,
      "logConfiguration": null,
      "entryPoint": null,
      "portMappings": [],
      "command": null,
      "linuxParameters": null,
      "cpu": 0,
      "environment": [
        {
          "name": "DOCKER_PROVIDER",
          "value": "ecs"
        },
        {
          "name": "NGINX_DOCKER_GEN_CONTAINER",
          "value": "nginx-gen"
        },
        {
          "name": "NGINX_PROXY_CONTAINER",
          "value": "nginx"
        }
      ],
      "ulimits": null,
      "dnsServers": null,
      "mountPoints": [
        {
          "readOnly": null,
          "containerPath": "/etc/nginx/certs",
          "sourceVolume": "certs"
        },
        {
          "readOnly": true,
          "containerPath": "/var/run/docker.sock",
          "sourceVolume": "docker"
        },
        {
          "readOnly": false,
          "containerPath": "/usr/share/nginx/html",
          "sourceVolume": "usr-share-nginx-html"
        },
        {
          "readOnly": false,
          "containerPath": "/etc/nginx/vhost.d",
          "sourceVolume": "usr-share-nginx-vhost"
        }
      ],
      "workingDirectory": null,
      "dockerSecurityOptions": null,
      "memory": 128,
      "memoryReservation": null,
      "volumesFrom": [],
      "image": "jrcs/letsencrypt-nginx-proxy-companion",
      "disableNetworking": null,
      "essential": false,
      "links": null,
      "hostname": null,
      "extraHosts": null,
      "user": null,
      "readonlyRootFilesystem": null,
      "dockerLabels": null,
      "privileged": null,
      "name": "jrcs-letsencrypt-nginx-proxy-companion"
    }
  ],
  "volumes": [
    {
      "name": "certs",
      "host": {
        "sourcePath": "/home/ec2-user/efs/nginx/certs"
      }
    },
    {
      "name": "docker",
      "host": {
        "sourcePath": "/var/run/docker.sock"
      }
    },

    {
      "name": "usr-share-nginx-vhost",
      "host": {
        "sourcePath": "/home/ec2-user/efs/nginx/vhost.d"
      }
    },
    {
      "name": "usr-share-nginx-html",
      "host": {
        "sourcePath": "/home/ec2-user/efs/nginx/html"
      }
    }
  ],
  "placementConstraints": [],
  "requiresCompatibilities": [
    "EC2"
  ],
  "cpu": null,
  "memory": null
}

Just remember to update the volume locations accordingly

Edit: pasted the wrong copy

All 12 comments

Hi. Additional configuration is required if you want to run this container on ECS.

Please check the DOCKER_PROVIDER environment variable under the Optional container environment variables section of the Readme.

@buchdag
Thanks for the answer!

Now i put the companion container's env DOCKER_PROVIDER = ecs DEBUG=true AND
ECS_ENABLE_CONTAINER_METADATA=true in /etc/ecs/ecs.config (because it was disabled by default)
and i maked a reboot.

Now, when i run "docker inspect", i got this new mount option:

"Source": "/var/lib/ecs/data/metadata/38b3f7e2-5e5a-44c5-8d77-a0e8394d6396/nginx",
"Destination": "/opt/ecs/metadata/fc6ae9c0-a092-42db-85b8-a4e441c8e67c",

But it's still returning exit code 1, what do i miss now?

Do you have the log output from the letsencrypt-nginx-proxy-companion container ?

@buchdag i put the env (DEBUG=true) but it didnt make any logs, where can i see them?

I'm afraid I won't be able to help you much, I don't even know how to check containers logs under ECS 馃槓

@myoung34 contributed the DOCKER_PROVIDER / ECS code, maybe he can assist you in troubleshooting your setup ?

DOCKER_PROVIDER = ecs DEBUG=true AND
ECS_ENABLE_CONTAINER_METADATA=true in /etc/ecs/ecs.config (because it was disabled by default)
and i maked a reboot.

DOCKER_PROVIDER = ecs and DEBUG=true need to be environment variables.
putting them into ecs.config is not the same thing. the ecs agent reads from there for values it expects. youll need to add these to your task definition as environment variables like

        "environment": [
          {   
            "name": "DOCKER_PROVIDER",
            "value": "ecs"
          },  
          {   
            "name": "DEBUG",
            "value": "true"
          }   
        ],  

I am having trouble getting this to work as well. I am getting
Deployment has not completed ...

for the following Dockerfile

version: '2'

services:
  nginx-web:
    image: nginx
    labels:
        com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
    ports:
      - "0.0.0.0:80:80"
      - "0.0.0.0:443:443"
    volumes:
      - /nginx/data/conf.d:/etc/nginx/conf.d
      - /nginx/data/vhost.d:/etc/nginx/vhost.d
      - /nginx/data/html:/usr/share/nginx/html
      - /nginx/data/certs:/etc/nginx/certs:ro
      - /nginx/data/htpasswd:/etc/nginx/htpasswd:ro
    logging:
      options:
        max-size: 4m
        max-file: 10

  nginx-gen:
    image: jwilder/docker-gen
    command: -notify-sighup nginx-web -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl 
/etc/nginx/conf.d/default.conf
    volumes:
      - /nginx/data/conf.d:/etc/nginx/conf.d
      - /nginx/data/vhost.d:/etc/nginx/vhost.d
      - /nginx/data/html:/usr/share/nginx/html
      - /nginx/data/certs:/etc/nginx/certs:ro
      - /nginx/data/htpasswd:/etc/nginx/htpasswd:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
    logging:
      options:
        max-size: 2m
        max-file: 10

  nginx-letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    volumes:
      - /nginx/data/conf.d:/etc/nginx/conf.d
      - /nginx/data/vhost.d:/etc/nginx/vhost.d
      - /nginx/data/html:/usr/share/nginx/html
      - /nginx/data/certs:/etc/nginx/certs:rw
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      NGINX_DOCKER_GEN_CONTAINER: nginx-gen
      NGINX_PROXY_CONTAINER: nginx-web
      DOCKER_PROVIDER: ecs
    logging:
      options:
       max-size: 2m
       max-file: 10
  httpd:
    image: httpd:alpine
    environment:
      VIRTUAL_HOST:  abcd.example.com
      LETSENCRYPT_HOST: abcd.example.com
      LETSENCRYPT_EMAIL: [email protected]

Could you put up a working example using the DOCKER_PROVIDER=ecs and say a simple httpd container?

in particular, it is unclear how to get the right network

in particular, it is unclear how to get the right network

Im not sure what you mean

As for the rest, have you enabled metadata lookup on the ecs cluster? the instances, ecs.config in particular

When going through Evert Ramos's examples all the docker containers were in a docker network webproxy. When doing this on standard EC2 machine, it works fine with some basic docker containers (e.g. httpd). For ECS I cannot specify the network it seems, so I guess everything just goes into bridge?

I did not set ecs.config specifically (not sure how to do it from the my machine; and I guess I don't need to ssh in to set it manually), I used the cli to create my cluster

ecs-cli configure --cluster clustecs --region eu-central-1 --default-launch-type EC2 --config-name clustecs
and all it shows in ecs.config is
ECS_CLUSTER=clustecs

How can I set the ECS_ENABLE_CONTAINER_METADATA from the command-line (or from the dashboard if needed)?

Im not sure, I dont use ecs-cli, but terraform and specify it in the userdata:

  user_data = <<EOF
#!/bin/bash
cat <<EOS >/etc/ecs/ecs.config
ECS_CLUSTER=${var.ecs_cluster_name}
ECS_CONTAINER_STOP_TIMEOUT=${var.ecs_sigterm_timeout}
ECS_AVAILABLE_LOGGING_DRIVERS=["awslogs", "syslog"]
ECS_ENGINE_TASK_CLEANUP_WAIT_DURATION=${var.ecs_task_cleanup_timeout}
ECS_ENABLE_TASK_IAM_ROLE=true
ECS_ENABLE_CONTAINER_METADATA=true
EOS
${var.user_data}
EOF
}

I was having the same issue. Turned out to be just a few typos.

Here is my working version:

{
  "family": "nginx",
  "taskRoleArn": "",
  "executionRoleArn": "",
  "networkMode": "none",
  "containerDefinitions": [
    {
      "dnsSearchDomains": null,
      "logConfiguration": null,
      "entryPoint": null,
      "portMappings": [
        {
          "hostPort": 80,
          "protocol": "tcp",
          "containerPort": 80
        },
        {
          "hostPort": 443,
          "protocol": "tcp",
          "containerPort": 443
        }
      ],
      "command": null,
      "linuxParameters": null,
      "cpu": 0,
      "environment": [
        {
          "name": "DOCKER_PROVIDER",
          "value": "ecs"
        },
        {
          "name": "NGINX_DOCKER_GEN_CONTAINER",
          "value": "nginx-gen"
        },
        {
          "name": "NGINX_PROXY_CONTAINER",
          "value": "nginx"
        }
      ],
      "ulimits": null,
      "dnsServers": null,
      "mountPoints": [
        {
          "readOnly": false,
          "containerPath": "/etc/nginx/certs",
          "sourceVolume": "certs"
        },
        {
          "readOnly": true,
          "containerPath": "/tmp/docker.sock",
          "sourceVolume": "docker"
        },
        {
          "readOnly": false,
          "containerPath": "/usr/share/nginx/html",
          "sourceVolume": "usr-share-nginx-html"
        },
        {
          "readOnly": false,
          "containerPath": "/etc/nginx/vhost.d",
          "sourceVolume": "usr-share-nginx-vhost"
        }
      ],
      "workingDirectory": null,
      "dockerSecurityOptions": null,
      "memory": 128,
      "memoryReservation": null,
      "volumesFrom": [],
      "image": "jwilder/nginx-proxy",
      "disableNetworking": null,
      "essential": true,
      "links": null,
      "hostname": null,
      "extraHosts": null,
      "user": null,
      "readonlyRootFilesystem": null,
      "dockerLabels": {
        "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy": ""
      },
      "privileged": null,
      "name": "nginx"
    },
     {
      "dnsSearchDomains": null,
      "logConfiguration": null,
      "entryPoint": null,
      "portMappings": [],
      "command": null,
      "linuxParameters": null,
      "cpu": 0,
      "environment": [
        {
          "name": "DOCKER_PROVIDER",
          "value": "ecs"
        },
        {
          "name": "NGINX_DOCKER_GEN_CONTAINER",
          "value": "nginx-gen"
        },
        {
          "name": "NGINX_PROXY_CONTAINER",
          "value": "nginx"
        }
      ],
      "ulimits": null,
      "dnsServers": null,
      "mountPoints": [
        {
          "readOnly": null,
          "containerPath": "/etc/nginx/certs",
          "sourceVolume": "certs"
        },
        {
          "readOnly": true,
          "containerPath": "/var/run/docker.sock",
          "sourceVolume": "docker"
        },
        {
          "readOnly": false,
          "containerPath": "/usr/share/nginx/html",
          "sourceVolume": "usr-share-nginx-html"
        },
        {
          "readOnly": false,
          "containerPath": "/etc/nginx/vhost.d",
          "sourceVolume": "usr-share-nginx-vhost"
        }
      ],
      "workingDirectory": null,
      "dockerSecurityOptions": null,
      "memory": 128,
      "memoryReservation": null,
      "volumesFrom": [],
      "image": "jrcs/letsencrypt-nginx-proxy-companion",
      "disableNetworking": null,
      "essential": false,
      "links": null,
      "hostname": null,
      "extraHosts": null,
      "user": null,
      "readonlyRootFilesystem": null,
      "dockerLabels": null,
      "privileged": null,
      "name": "jrcs-letsencrypt-nginx-proxy-companion"
    }
  ],
  "volumes": [
    {
      "name": "certs",
      "host": {
        "sourcePath": "/home/ec2-user/efs/nginx/certs"
      }
    },
    {
      "name": "docker",
      "host": {
        "sourcePath": "/var/run/docker.sock"
      }
    },

    {
      "name": "usr-share-nginx-vhost",
      "host": {
        "sourcePath": "/home/ec2-user/efs/nginx/vhost.d"
      }
    },
    {
      "name": "usr-share-nginx-html",
      "host": {
        "sourcePath": "/home/ec2-user/efs/nginx/html"
      }
    }
  ],
  "placementConstraints": [],
  "requiresCompatibilities": [
    "EC2"
  ],
  "cpu": null,
  "memory": null
}

Just remember to update the volume locations accordingly

Edit: pasted the wrong copy

So, i want to thank everyone, now i have a working solution, using only jwilder + companion containers.
Steps:

  1. Set ECS_ENABLE_CONTAINER_METADATA=true in /etc/ecs/ecs.config;
  2. Set container's env DOCKER_PROVIDER = ecs

Final TaskDefinition JSON:

{
    "ipcMode": null,
    "executionRoleArn": null,
    "containerDefinitions": [
        {
            "dnsSearchDomains": null,
            "logConfiguration": null,
            "entryPoint": null,
            "portMappings": [
                {
                    "hostPort": 80,
                    "protocol": "tcp",
                    "containerPort": 80
                },
                {
                    "hostPort": 443,
                    "protocol": "tcp",
                    "containerPort": 443
                }
            ],
            "command": null,
            "linuxParameters": null,
            "cpu": 0,
            "environment": [
                {
                    "name": "DOCKER_PROVIDER",
                    "value": "ECS"
                }
            ],
            "ulimits": null,
            "dnsServers": null,
            "mountPoints": [
                {
                    "readOnly": true,
                    "containerPath": "/tmp/docker.sock",
                    "sourceVolume": "docker-sock"
                },
                {
                    "readOnly": null,
                    "containerPath": "/etc/nginx/certs",
                    "sourceVolume": "var-certs"
                },
                {
                    "readOnly": null,
                    "containerPath": "/usr/share/nginx/html",
                    "sourceVolume": "var-ngnix-html"
                },
                {
                    "readOnly": null,
                    "containerPath": "/etc/nginx/vhost.d",
                    "sourceVolume": "var-ngnix-vhostd"
                }
            ],
            "workingDirectory": null,
            "secrets": null,
            "dockerSecurityOptions": [],
            "memory": 150,
            "memoryReservation": null,
            "volumesFrom": [],
            "image": "jwilder/nginx-proxy:0.3.0",
            "disableNetworking": null,
            "interactive": null,
            "healthCheck": null,
            "essential": true,
            "links": null,
            "hostname": null,
            "extraHosts": null,
            "pseudoTerminal": null,
            "user": null,
            "readonlyRootFilesystem": null,
            "dockerLabels": {
                "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy": ""
            },
            "systemControls": null,
            "privileged": null,
            "name": "nginx-proxy"
        },
        {
            "dnsSearchDomains": null,
            "logConfiguration": null,
            "entryPoint": null,
            "portMappings": [
                {
                    "hostPort": 8080,
                    "protocol": "tcp",
                    "containerPort": 8000
                }
            ],
            "command": null,
            "linuxParameters": null,
            "cpu": 0,
            "environment": [
                {
                    "name": "VIRTUAL_HOST",
                    "value": "yourcompany.com"
                },
                {
                    "name": "LETSENCRYPT_EMAIL",
                    "value": "[email protected]"
                },
                {
                    "name": "VIRTUAL_PORT",
                    "value": "8000"
                },
                {
                    "name": "LETSENCRYPT_HOST",
                    "value": "yourcompany.com"
                }
            ],
            "ulimits": null,
            "dnsServers": null,
            "mountPoints": [],
            "workingDirectory": null,
            "secrets": null,
            "dockerSecurityOptions": null,
            "memory": 128,
            "memoryReservation": null,
            "volumesFrom": [],
            "image": "jwilder/whoami",
            "disableNetworking": null,
            "interactive": null,
            "healthCheck": null,
            "essential": true,
            "links": null,
            "hostname": null,
            "extraHosts": null,
            "pseudoTerminal": null,
            "user": null,
            "readonlyRootFilesystem": null,
            "dockerLabels": null,
            "systemControls": null,
            "privileged": null,
            "name": "whoami"
        },
        {
            "dnsSearchDomains": null,
            "logConfiguration": null,
            "entryPoint": null,
            "portMappings": [],
            "command": null,
            "linuxParameters": null,
            "cpu": 0,
            "environment": [
                {
                    "name": "DOCKER_PROVIDER",
                    "value": "ECS"
                }
            ],
            "ulimits": null,
            "dnsServers": null,
            "mountPoints": [
                {
                    "readOnly": null,
                    "containerPath": "/etc/nginx/certs",
                    "sourceVolume": "var-certs"
                },
                {
                    "readOnly": true,
                    "containerPath": "/var/run/docker.sock",
                    "sourceVolume": "docker-sock"
                },
                {
                    "readOnly": null,
                    "containerPath": "/usr/share/nginx/html",
                    "sourceVolume": "var-ngnix-html"
                },
                {
                    "readOnly": null,
                    "containerPath": "/etc/nginx/vhost.d",
                    "sourceVolume": "var-ngnix-vhostd"
                }
            ],
            "workingDirectory": null,
            "secrets": null,
            "dockerSecurityOptions": null,
            "memory": null,
            "memoryReservation": null,
            "volumesFrom": [],
            "image": "jrcs/letsencrypt-nginx-proxy-companion",
            "disableNetworking": null,
            "interactive": null,
            "healthCheck": null,
            "essential": false,
            "links": null,
            "hostname": null,
            "extraHosts": null,
            "pseudoTerminal": null,
            "user": null,
            "readonlyRootFilesystem": null,
            "dockerLabels": null,
            "systemControls": null,
            "privileged": null,
            "name": "jrcs-letsencrypt-nginx-proxy-companion"
        }
    ],
    "memory": "150",
    "taskRoleArn": null,
    "family": "proxy-reverso",
    "pidMode": null,
    "requiresCompatibilities": [
        "EC2"
    ],
    "networkMode": null,
    "cpu": null,
    "volumes": [
        {
            "name": "docker-sock",
            "host": {
                "sourcePath": "/var/run/docker.sock"
            },
            "dockerVolumeConfiguration": null
        },
        {
            "name": "var-certs",
            "host": {
                "sourcePath": "/var/ngnix/certs/"
            },
            "dockerVolumeConfiguration": null
        },
        {
            "name": "var-ngnix-html",
            "host": {
                "sourcePath": "/var/ngnix/html"
            },
            "dockerVolumeConfiguration": null
        },
        {
            "name": "var-ngnix-vhostd",
            "host": {
                "sourcePath": "/var/ngnix/vhost.d"
            },
            "dockerVolumeConfiguration": null
        }
    ],
    "placementConstraints": []
}
Was this page helpful?
0 / 5 - 0 ratings