Can I use --name value within the image?

When I start a container with docker run --name {SomeName} ..., is there any way I can find out the value of SomeName in the container and use that to set an environment variable?


Not sure if it is readily available but in the event it is not, you can simply add it as an environment variable within the docker run command itself:

That’s what I’m doing now but it means I’m duplicating that value on the command. I was hoping to find a way to stop doing that and shorten my command a bit.

To my knowledge, the container is oblivious of the --name flag. The --name is relevant to the docker host and I believe the container is not aware it is a container.