-1

I have a container that listens to port 8080. I want to spin up 3 instances of the same container on the same host without having to do port forwarding. I want to access each of the instances using a unique IP.

I am running Docker via Boot2Docker since I am running it on a Mac machine. I do not intend to run multiple instances of Boot2Docker as it is memory intensive.

The reason I do not want to do port forwarding is because my application is a distributed application. Each node in the cluster assumes that its peer is running on the same port.

ChaitanyaBhatt
  • 1,158
  • 14
  • 11
  • I will do that in Vagrant/CoreOS, start three CoreOS vagrant instances, and run the `docker pull` and `docker run`, with that, you have three IP addresses with same port. – BMW Jun 16 '15 at 04:42

1 Answers1

0

(Maybe there are better solutions within boot2docker.)

For a fast solution, I recommend to do this via Vagrant.

** review this document. https://coreos.com/docs/running-coreos/platforms/vagrant/

update config.rb file

config.rb

# Size of the CoreOS cluster created by Vagrant
$num_instances=3

** start vagrant with three CoreOS instances. Start the machine(s):

vagrant up

List the status of the running machines:

$ vagrant status
Current machine states:

core-01                   running (virtualbox)
core-02                   running (virtualbox)
core-03                   running (virtualbox)

This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.

** login each instance and start the docker container

docker pull <image>
docker run ...

Another way to do that is via Docker machine

Note: Machine is currently in beta, so things are likely to change. We don't recommend you use it in production yet.

Machine makes it really easy to create Docker hosts on your computer, on cloud providers and inside your own data center. It creates servers, installs Docker on them, then configures the Docker client to talk to them.

Relative document : https://docs.docker.com/machine/

BMW
  • 42,880
  • 12
  • 99
  • 116
  • Thanks for the really elaborate and descriptive answer. I will try it and let you know how it goes. I am pumped up to know there is something out there! :) – ChaitanyaBhatt Jun 16 '15 at 05:10
  • Another way to do that is via Docker machine, relative document is here: https://docs.docker.com/machine/ – BMW Jun 16 '15 at 21:20