Docker Community Forums

Share and learn in the Docker community.

Elastic IP with Docker Cloud instance

amazonwebservices

(Tom Kazakov) #1

Hi guys,

Please advise on how to use an AWS Elastic IP assigned to the Docker Cloud instance?

My goal is to get a second level domain (example.com) pointing with an A record to a Docker Cloud service.
CNAME record can be used only if there’re no other records on the set (which is obviously not a case: I have MX and some other stuff).
A record should be set to an IP, which I can get from instance settings but I’m not really sure if it’s persistent enough (the doc says it will be removed when the instance is stopped).

The problem with Elastic IP is the EC2 instance IP address change:

  1. When I first deploy a node from Docker cloud and the assign Elastic IP from AWS console I don’t seem to be able to edit node IP address on the Docker Cloud panel; and the system isn’t updating the info by itself.
  2. When I alternatively setup and interface with Elastic IP connected on the AWS first, and even poind a node to it while deploying it seems to only use a subnetwork, not the interface with Elastic IP assigned to it.

TL;DR: Is it possible to change a node IP when the node is already deployed? Or is there some way to put the node into a pre-created AWS EC2 instance or assign a specified AWS EC2 Network Interface?


(Vidsy.co (Charlie)) #2

I would instead setup an ELB that connects to your EC2 instances. And then point the Route53 record at the ELB.

It’s what we’re currently using, and works pretty well.

@revett


(Tom Kazakov) #3

Thanks, that sounds like a valid solution to me!
The only problem is that ELB is a bit pricey, don’t you think?


(Gigonaut) #4

once the instance is up and running, if you ssh into it, you can restart the agent and it should reconnect with docker-cloud. At least it did for me.

Once your are ssh’d into the box:

service dockercloud-agent restart


(Ultimaratioregis) #5

Change the IP would be much easier to solve the issue, but i dont know if theres any security breach allowing it.

If you already added the elastic IP and not did the steps of https://docs.docker.com/docker-cloud/tutorials/ssh-into-a-node/, you will not be able to restart the service.

I had to:

  • terminate the node and create it again
  • add ssh access
  • Add the elastic IP
  • ssh into the node
  • restart the agent >> service dockercloud-agent restart

I dont know you remove the elastic ip you get the same ip you had before. If yes, theres no need to terminate the node.

I found all my answers in the forum. Thanks all.
PS: sorry for any english mistakes, i am trying to improve.


(Antony Jones) #6

Just because I’m probably the ultimate lazy developer, I’ve figured out a way to do this via AWS without any SSHing or ELBs or otherwise. A few simple steps.

  • Create the node via Docker Cloud
  • Go into the AWS console and assign the Elastic IP as you wish. AWS will restart your node.
  • Once it has started up successfully (the public IP will not have updated), go into the AWS console and simply reboot the instance.
  • PROFIT!

I think the reason this works, is that user-data on the instance is some sort of init script, of which the last line is restarting the docker agent. Rebooting the instance simply re-runs this script with the Elastic IP already assigned.