containous / traefik-library-image

ARCHIVED
https://github.com/traefik/traefik-library-image
Apache License 2.0
218 stars 60 forks source link

Alpine image: allows CMD override to shell when a non Traefik command is provided #51

Closed dduportal closed 5 years ago

dduportal commented 5 years ago

Related to https://github.com/docker-library/official-images/pull/6106#issuecomment-503314187

TL;DR; the "official Docker image test suite" run by Docker requires the CMD to be overridden when an image has a shell (as the Alpine Traefik). With v2.0-alpha6, the Traefik CLI accepts non flags options, which leads to issues.

This change is only alpine, and delegate to the main shell the user-provided CMD if it is not a command recognized by traefik.

So the following exemple works:

# print Traefik version
docker run --rm traefik:<tag> version
# print Traefik help about healthcheck Traefik's command
docker run --rm traefik:<tag> healthcheck --version
# print "Hello world-<random number>-<random number>" with a message in the log that switched to shell
docker run --rm traefik:<tag> echo Hello world-$RANDOM-$RANDOM

Important: works with 1.7.12, but for 2.0, it requires https://github.com/containous/traefik/pull/4977 to be merged!