I would like to set the hostname for a Docker container deployed on AWS Elastic Beanstalk manually. You can set the hostname when spinning up a container with docker run -h HOSTNAME
, but I can't figure out how (or even if) to pass custom arguments to the docker run
command.
The Dockerrun.aws.json file seems a likely candidate, but there are no documented keys that do what I want.
Does anyone know if this is possible?
As far as I know this is not supported out of the box.
A possible hack here is to exploit EB's poor parsing of environment variables. You can setup an environment variable such as:PARAM1=dummy -h MYHOSTNAME
EB doesn't quote the parameters, so your -h
part will be embedded into the docker run command.
I didn't try it myself.
Another option would be to create an ebextension
file to patch the /opt/elasticbeanstalk/hooks/appdeploy/pre/04run.sh
script, injecting the -h MYHOST
line into it.
Not sure about single docker container deployment i.e v1 since i haven't tried that yet but they are definitely supported in v2 i.e multi container deployment. You can adda container hostname by putting below in Dockerrun.aws.json
-
"hostname": "this-is-my-container-hostname"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With