Name flag not working
stevegroom opened this issue · comments
I do not get the expected Name: MyName
at the beginning of the whoami http response.
I am testing a complex traefik scenario and have multiple whoami containers running and want to tag each one clearly with the Name option.
docker run -d -P --name whoami -e name="MyName" traefik/whoami
curl 127.0.0.1:59707
Hostname: f98a3f6efd8a
IP: 127.0.0.1
IP: 172.17.0.2
RemoteAddr: 172.17.0.1:39884
GET / HTTP/1.1
Host: 127.0.0.1:59707
User-Agent: curl/7.68.0
Accept: */*
In app.go:
207
208 if name != "" {
209 _, _ = fmt.Fprintln(w, "Name:", name)
210 }
211
212 hostname, _ := os.Hostname()
213 _, _ = fmt.Fprintln(w, "Hostname:", hostname)
Steve.
$ docker run --help
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Run a command in a new container
Options:
...
-e, --env list Set environment variables
...
the env var for the name is WHOAMI_NAME
.
$ docker run -d -p 80:80 --name whoami -e WHOAMI_NAME="MyName" traefik/whoami
$ curl localhost:80
Name: MyName
Hostname: d306b50f3fc9
IP: 127.0.0.1
IP: 172.17.0.2
RemoteAddr: 172.17.0.1:50208
GET / HTTP/1.1
Host: localhost
User-Agent: curl/7.83.1
Accept: */*
If you want to use the CLI flags:
$ docker run -d -p 80:80 --name whoami traefik/whoami --name=MyName
$ curl localhost:80
Name: MyName
Hostname: 72a4803cdf7a
IP: 127.0.0.1
IP: 172.17.0.2
RemoteAddr: 172.17.0.1:38316
GET / HTTP/1.1
Host: localhost
User-Agent: curl/7.83.1
Accept: */*
I suggest the README.md have a better example:
replace
docker run -d -P --name iamfoo traefik/whoami
with
docker run -d -P --name containername traefik/whoami --name reportedname
Steve.