Search code examples
dockeramazon-ec2amazon-ecstraefik

Traefik with custom config on ECS


How can I upload an image of the traefik on ECS with the configuration file embedded?

docker run -d -p 8080: 8080 -p 80:80 \
-v $PWD/traefik.toml:/etc/traefik/traefik.toml \
-v /var/run/docker.sock:/var/run/docker.sock \
traefik: v1.7

How to reproduce -v $PWD /traefik.toml:/etc/traefik/traefik.toml on ECS?


Solution

  • You are looking to do a Bind Mount and 'mountPoints' in a ContainerDefinition within ECS task definition is equivalent of Docker Bind mounts:

    "volumes": [
        {
          "name": "traefikroot",
          "host": {
            "sourcePath": "/traefikroot"
          }
        }
      ]
    

      "mountPoints": [
        {
          "sourceVolume": "traefikroot",
          "containerPath": "/etc/traefik"
        }
      ]
    

    Any files at '/traefikroot' will be presented to container at '/etc/traefik'.

    Please see detailed example here: - https://docs.aws.amazon.com/AmazonECS/latest/developerguide/bind-mounts.html#bind-mount-examples