I am trying to replicate the advice for running Nginx and Certbot in containers in an Amazon ECS environment. The advice I have been following can be found [here](https://medium.com/@pentacent/nginx-and-lets-encrypt-with-docker-in-less-than-5-minutes-b4b8a60d3a71). This has been great but I am struggling with the last step which is to ensure the certificates are updated in the future. For example the recommended command for Nginx is:

```
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"

```

On a local container this worked but ECS needs this in the string array format so I used the following command (which worked locally):

```
command: ["/bin/sh","-c","while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\""]

```

I added the same to the ECS console. However, the task fails to start and in the output I get:

```
/bin/sh: 1: wait: Illegal number: 1{!}
nginx: invalid option: "off"
/bin/sh: 1: ": not found

```

The command in the Task JSON looks like this:

```
"command": [
        "/bin/sh",
        "-c",
        "while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \\\"daemon off;\\\""
      ],

```

It looks like this is failing to interpret correctly but I am not sure how I should be quoting (or escaping) this for it to work correctly?