Set the node name of the Docker container on the elastic beanstalk

I would like to set the host name for the Docker container deployed to AWS Elastic Beanstalk manually. You can set the host name when formatting the container using docker run -h HOSTNAME , but I cannot figure out how (or even if) to pass user arguments to the docker run .

The Dockerrun.aws.json file seems like a likely candidate, but there are no documented keys that do what I want.

Does anyone know if this is possible?

+6
source share
3 answers

As far as I know, this is not supported out of the box.

A possible hack here is to use a poor analysis of environment variables in EB. You can set the environment variable, for example:
PARAM1=dummy -h MYHOSTNAME
EB does not quote parameters, so your -h part will be built into the docker launch command. I have not tried it myself.

Another option is to create an ebextension file to fix the /opt/elasticbeanstalk/hooks/appdeploy/pre/04run.sh script by entering the -h MYHOST line in it.

+2
source

You can set the host name of the container by specifying it as an environment variable.

 HOSTNAME=your-name 
0
source

If you have several instances, we fixed the old platforms with the following script, but you can transfer it to new platforms. Example .ebextensions/01-docker-hostname.config :

 files: "/opt/elasticbeanstalk/hooks/appdeploy/pre/04a_set_hostname.sh": mode: "000755" owner: root group: root content: | #!/usr/bin/env bash hostname $(hostname -f | cut -d"." -f1,2) sed -i "s/docker run -d \\\/docker run -d -h $(hostname) \\\/" /opt/elasticbeanstalk/hooks/appdeploy/enact/04run.sh 

As you can see, our script always corrects the run of the script. EB runs scripts in order of file names. Therefore, you must be sure that your script is running before the script runs.

0
source

Source: https://habr.com/ru/post/982947/


All Articles