Amazon-ecs-agent: Specifying "host" to running ecs-launched containers

Created on 16 Jun 2015  路  21Comments  路  Source: aws/amazon-ecs-agent

When manually starting a container ("docker run") you can do --host=myhostname which sets the hostname of running container.

For various licensing reasons a piece of software we have requires the hostname to be "bi-01" yet when I deploy via ecs, I cannot provide a hostname in the configuration.

Am I missing something?

kinenhancement

Most helpful comment

Any information about dynamic hostname support?

All 21 comments

You're not missing anything; I'll take this as a feature request.
Thanks for the suggestion and information about your use-case.

We could also use access to $HOSTNAME for flags, for example nsqd needs to expose the address of the host it lives on. nsq is arguably not really designed for this sort of thing but we're heavy users and stuck using docker run until then

We have the same usecase as tj. Would be great to be able to use the $HOSTNAME variable of the host and pass it to the docker containers. Especially helpful when logging from inside the container, as it's then easier to identify the right host instance when the logs are in some central location (CloudWatch Logs, Loggly, ...)

+1 for

Would be great to be able to use the $HOSTNAME variable of the host and pass it to the docker containers.

+1 for this feature

Would be great to be able to use the $HOSTNAME variable of the host and pass it to the docker containers.

+1 we are running ECS on instances managed by OpsWorks and they give those instances really nice host names that I would really like to reuse :smile_cat:

+1.

+1

Hi @tj I've faced the same problem with nsqd and -broadcast-address flag. The workaround I've found is to dynamically detect public ip address of the container's host and use it as a broadcast address. Look at my solution https://github.com/clickberry/nsqd-ecs. It works well for ECS services, so you can easily scale up number of nsqd instances and all of them will retrieve their public IPs and register in nsqlookupd.

+1

This is actually required to for running things like Akka, which require an explicit hostname/port to be provided if you are running behind a NAT/docker container, i.e. see

http://doc.akka.io/docs/akka/snapshot/additional/faq.html
http://serverfault.com/q/695393

+1
To be able to publish host's hostname together with container id to centralised logging.

Hostname is now available in ECS using the 1.5.0 version of the Agent. You should now be able to specify hostname for a container in your task definitions in the ECS console. With respect to retrieving the underlying host's hostname, I'm closing this issue in favor of #3.

how we defined dynamic hostname in task definition , as we don't know which container is going to run in which ECS instances. we have ECS cluster with 5 instances and container can run in any instances.

Would be cool if you could give us a quick example of how this would look like in the JSON of the task definition when using this with 1.5.0.

@apeiniger, It looks like "hostname": "thisismyhostname" inside the container definition. Details of all the task definition parameters are available in our documentation.

@hridyeshpant, dynamic hostnames are not currently available. I'm really interested in hearing more about what dynamism you'd like for hostname; can you either open a new issue here or a thread on our forum?

@samuelkarp we are using splunkforwarder as ECS docker container but the issue is, inside the splunkforwarder container the host name is the container id and then splunkforwarder communicate to splunk deployment server but the issue is the splunk deployment server is configured to look at the host name to determine which output app it should give to the client. because the host name is container id not actual host EC2 instance. splunk deployment server is not able to communicate.
we can not hardcode host name in task definition as we are running ECS cluster with multiple instances , and we dont know which instance will be used . So it will be good we can have actual hostname environment value inside the container.

@mdedetrich said:

This is actually required to for running things like Akka

:+1:

This is exactly my situation getting Apache Spark to run on ECS.

I could also solve this via ExtraHosts if CloudFormation ECS::TaskDefinition supported it...

ExtraHosts is lacking functionality, because I frequently use it with TaskDefinition, but when I started using CloudFormation I should step on my neck to pass external hostnames to dockerized container. :(

I have a distributed system running on ECS with the same docker configuration but every container has his own internal config. It will be grate to have diferent hostname in every container to download the configuration depending who is doing it.

I'm also interesting in the dynamic hostnames. Right now we can either use container_id as hostname (omit hostname in the container configuration) or specify static hostname.

And this brings mess in the monitoring. We filter CPU by hostname and it could be 150% (5 containers using 30% CPU each). I know that this could be fixed tweaking monitoring. But newrelic don't allow this.

Any information about dynamic hostname support?

Was this page helpful?
0 / 5 - 0 ratings