docker / machine

Machine management for a container-centric world
https://docs.docker.com/machine/
Apache License 2.0
6.63k stars 1.97k forks source link

--n-instances flag for machine create #61

Open nathanleclaire opened 9 years ago

nathanleclaire commented 9 years ago

Suppose I want to use docker-machine to spin up a simple architecture of two instances running the same application behind another instance which serves as a proxy / load balancer to the two. It'd be nice to spin up the application instances using something like:

$ machine create --driver ec2 --n-instances 2 load_balanced_app
...
$ machine ls
NAME                  ACTIVE   DRIVER   STATE     URL
default                                           unix:///var/run/docker.sock
load_balanced_app_1   *        ec2      Running   tcp://54.183.69.81:2375
load_balanced_app_0            ec2      Running   tcp://54.183.67.108:2375

I know that the Amazon API allows you to specify the number of instances desired to the RunInstances call, I'd imagine that similar args exist for other providers. If not, they can probably be worked around by making multiple calls.

thaJeztah commented 9 years ago

Except, machine will only create a "clean" docker host and not an app instance. Would be nice though to be able to spin up X machines and automatically have them registered with Docker Swarm to create a cluster.

Iirc, Ben mentioned during DockerCon that that (or similar) was already on the roadmap.

nathanleclaire commented 9 years ago

Except, machine will only create a "clean" docker host and not an app instance

Yes, to be clear, this is still the expected and desired behavior, the request is simply to be able to create several "clean" machines at once. Then the application components can be deployed using docker run.

Tebro commented 9 years ago

I would love to see what @thaJeztah is talking about. Would let me spin up a quick swarm for some testing, and then remove it when I am done. Would also allow development environments to be more like production if production runs on multiple hosts.

thaJeztah commented 9 years ago

For testing, I was even thinking if it would be possible to create a docker-in-docker (https://github.com/jpetazzo/dind) driver. I haven't done a lot with dind and it would require some changes (We'll probably need ssh, so a process manager as well), but that would be interesting.

emilevauge commented 9 years ago

@thaJeztah Just created it :) https://github.com/EmileVauge/docker-cluster

thaJeztah commented 9 years ago

@EmileVauge ah, fun! Will give it a spin (if I find some time.. LOL)

dnephin commented 9 years ago

For testing, I was even thinking if it would be possible to create a docker-in-docker driver

@thaJeztah Yes, I want this too! Do you know if there's been any work to create one? If not, I think I'll create a new issue and look into it some more.

@EmileVauge cool idea, but not quite a driver.

I think what @thaJeztah was getting at was something like docker-machine create --driver dind ... which would launch a dind container on the currently configured docker instance, and have it run a new docker daemon.

That would be really awesome for testing anything that needs multiple docker hosts.

thaJeztah commented 9 years ago

@dnephin I don't think there's an open issue for that; and you described my use case correctly; basically create a local "swarm" cluster, obviously just for testing, to experiment with Swarm features (and without the overhead of running multiple virtual machines, or (cloud) instances)

Kosta-Github commented 8 years ago

IMHO, this feature is useful for spinning up several docker machines simultaneously (e.g., for creating a cluster on AWS) not just for testing ...

:+1:

FlorianHeigl commented 7 years ago

Would be nice if this would be looked at again. Basically the "interesting" side project docker-in-docker went through with high attention but the part that would have actual benefit for autoscaling etc. did not go through. That is just a bit weird... :-) Since you can delete multiple machines (rm one two three) it would be really nice for consistency to be able to do both directions.

Doing it via a shell loop is a workaround but relies on there never be any dangerous lock / tempfile implementations in docker-machine.

I'm using the OpenNebula driver which could easily launch 3 VMs every few seconds.