Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Docker container hostname on Elastic Beanstalk

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?

like image 642
Josh Glover Avatar asked Feb 24 '15 14:02

Josh Glover


Video Answer


2 Answers

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.

like image 164
Tal Avatar answered Sep 29 '22 07:09

Tal


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"
like image 34
vivekyad4v Avatar answered Sep 29 '22 08:09

vivekyad4v