Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker as a Vagrant provider #404

Closed
shykes opened this issue Apr 12, 2013 · 31 comments
Closed

Docker as a Vagrant provider #404

shykes opened this issue Apr 12, 2013 · 31 comments

Comments

@shykes
Copy link
Contributor

shykes commented Apr 12, 2013

There has been interest in using Docker as a provider to run Vagrant boxes - eg. as a backend for "vagrant up", "vagrant ssh", "vagrant bundle"...

This might require a little bit of creative hacking, since docker containers don't map perfectly to regular servers (eg. you can't run multiple commands on them, etc.).

But it would be really cool to drop an existing Vagrant project and get fully functional docker images as a result!

@shykes
Copy link
Contributor Author

shykes commented Apr 12, 2013

cc @destructuring

@dstrctrng
Copy link

I'm going to work on this.

@shykes
Copy link
Contributor Author

shykes commented Apr 19, 2013

Playing with it as well. @destructuring do you have something up somewhere that I could play with?

@gerred
Copy link

gerred commented Apr 19, 2013

Hi @destructuring if you need help with this, I'd be glad to help. Getting it work with multi-vm and provisioners working. I'll start playing with it.

@shykes
Copy link
Contributor Author

shykes commented Apr 20, 2013

Since there are a lot of concurrent efforts to do this, I created a placeholder pull request to coordinate. Please check out "contributing" notes in #440.

@jpetazzo
Copy link
Contributor

Notes of today's brainstorming session:
https://gist.github.com/jpetazzo/5423572

On Fri, Apr 19, 2013 at 5:35 PM, Solomon Hykes notifications@github.comwrote:

Since there are a lot of concurrent efforts to do this, I created a
placeholder pull request to coordinate. Please check out "contributing"
notes in #440 #440.


Reply to this email directly or view it on GitHubhttps://github.com//issues/404#issuecomment-16695986
.

@fgrehm
Copy link
Contributor

fgrehm commented Apr 20, 2013

Hey guys,

Since I was also one of those trying to make this happen I got some thoughts to share. Please keep in mind that I wrote those notes after 2 or 3 days playing with Docker and it was a while ago, so there's a huge potential that be some stuff might not make sense for advanced docker users out there ;-)

I'm also behind the "pure lxc" provider for vagrant so I might be able to contribute with the Docker provider implementation itself in case you guys need an extra pair of hands ;) I actually don't think a Docker provider would be a "competitor" to the pure lxc driver since my goal is to have it as a replacement to VirtualBox for Linux users, what you guys have done here with Docker is actually something a lot bigger.

@shykes
Copy link
Contributor Author

shykes commented Apr 23, 2013

Thanks Fabio! I'm preparing detailed answers to the questions in your notes.

@solomonstre
@getdocker

On Fri, Apr 19, 2013 at 7:51 PM, Fabio Rehm notifications@github.com
wrote:

Hey guys,
Since I was also one of those trying to make this happen I got some thoughts to share. Please keep in mind that I wrote those notes after 2 or 3 days playing with Docker and it was a while ago, so there's a huge potential that be some stuff might not make sense for advanced docker users out there ;-)

I'm also behind the "pure lxc" provider for vagrant so I might be able to contribute with the Docker provider implementation itself in case you guys need an extra pair of hands ;) I actually don't think a Docker provider would be a "competitor" to the pure lxc driver since my goal is to have it as a replacement to VirtualBox for Linux users, what you guys have done here with Docker is actually something a lot bigger.

Reply to this email directly or view it on GitHub:
#404 (comment)

@fgrehm
Copy link
Contributor

fgrehm commented Apr 25, 2013

(pasting my notes as a comment here as asked by @shykes on the gist)


To kick off the provider would be nice to have the big picture of out how Vagrant features / commands map to docker "stuff". These are thoughts about how the integration might look like under the hood:


vagrant up

  • how can we tell docker to "just start" a container? "docker start base" would start the base image right?
  • would probably need to commit the base "box" image and interact with that
  • would it make sense to have a "commandless" docker run -d <image>?
  • on "pure lxc" it basically means a "lxc-create" if the container has not been created yet and a "lxc-start -d"
  • how can we get the container IP from the command line to SSH into it?

shared folders

  • I saw some github issue action a while ago that there was some thinking around something related to that (something like data volumes?)
  • on "pure lxc" I just pass in '-s lxc.mount.entry=...' to lxc-start

vagrant box

  • does it map directly to docker images? what are the contents of an image?
  • all boxes will need to have an ssh server running so that people can use provisioners and other plugins that depend on it. does the base image come with it? I can't remember now
  • on "vanilla lxc" we have
    • a metadata.json with optional template params for lxc-create (this file is required by vagrant and just needs to have a "provider" key, the rest is up to us)
    • the rootfs tarball
    • the lxc template script which gets symlinked to the right folder so that "lxc-create" finds it
    • the current lxc template script is the same that comes with ubuntu 12.10 without the download / debootstrap part (i handle that when packaging the box)

vagrant halt

  • maps to "docker stop" + "docker wait"?

vagrant destroy

  • maps to "docker rm" ?

port forwarding

  • could use docker's built in port forwarding + a custom "vagrant port" command to lookup the public ports NATed
  • it won't work for localhost redirects, we could use "redir" as it is currently implemented on vagrant-lxc alread

@shykes
Copy link
Contributor Author

shykes commented Apr 26, 2013

On Thu, Apr 25, 2013 at 3:37 PM, Fabio Rehm notifications@github.comwrote:

(pasting my notes as a comment here as asked by @shykeshttps://github.com/shykeson the gist)

Thanks Fabio!


To kick off the provider would be nice to have the big picture of out how
Vagrant features / commands map to docker "stuff". These are thoughts about

how the integration might look like under the hood:

vagrant up

  • how can we tell docker to "just start" a container? "docker start
    base" would start the base image right?

"docker start base" would be incorrect - you can only start/stop a
container, which you need to create with "docker run".

  • would probably need to commit the base "box" image and interact with
    that
  • would it make sense to have a "commandless" docker run -d ?

Yes, you could do "docker run -d $IMAGE sshd", followed by multiple ssh
calls as needed.

  • on "pure lxc" it basically means a "lxc-create" if the container has
    not been created yet and a "lxc-start -d"
  • how can we get the container IP from the command line to SSH into it?
BOX=$(docker run -d -p 22 $IMAGE sshd)
ssh localhost $(docker port $BOX 22)

You can replace localhost with any public IP of the host.


shared folders

  • I saw some github issue action a while ago that there was some
    thinking around something related to that (something like data volumes?)

Yes, that would probably be done with data volumes. Of course if docker is
itself running a virtualbox machine, you will need 2 layers of sharing :)

  • on "pure lxc" I just pass in '-s lxc.mount.entry=...' to lxc-start

Yes, data volumes are basically a wrapper around that.


vagrant box

  • does it map directly to docker images? what are the contents of an
    image?

I don't think it maps directly. Taking the EC2 and Rackspace providers as
examples: the developer needs to add a provider-specific configuration
option with the name of a docker image.

  • all boxes will need to have an ssh server running so that people can
    use provisioners and other plugins that depend on it. does the base image
    come with it? I can't remember now

It doesn't, but we could provide special vagrant images with all the
requirements pre-installed: sshd, puppet, chef etc.

  • on "vanilla lxc" we have
    • a metadata.json with optional template params for lxc-create
      (this file is required by vagrant and just needs to have a "provider" key,
      the rest is up to us)
    • the rootfs tarball
    • the lxc template script which gets symlinked to the right folder
      so that "lxc-create" finds it
    • the current lxc template script is the same that comes with
      ubuntu 12.10 without the download / debootstrap part (i handle that when
      packaging the box)

vagrant halt

  • maps to "docker stop" + "docker wait"?

Yeah something like that.


vagrant destroy

  • maps to "docker rm" ?

Yes.


port forwarding

  • could use docker's built in port forwarding + a custom "vagrant
    port" command to lookup the public ports NATed

How do you do that in the vanilla lxc provider? How does regular Vagrant
handle port forwarding? Maybe we could align with that?

  • it won't work for localhost redirects, we could use "redir" as it is
    currently implemented on vagrant-lxc alread

Localhost redirects work on docker now :)

@fgrehm
Copy link
Contributor

fgrehm commented May 3, 2013

@shykes just saw your reply today. re port forwarding on vagrant / vagrant-lxc, vagrant uses VBox port forwarding and vagrant-lxc only supports localhost redirects with redir atm
BTW, it seems that there is enough information to put up a high level overview of what should happen under the hood for each vagrant feature / command right? have you guys done this already?

@frankscholten
Copy link

Would be an awesome feature!

@denibertovic
Copy link
Contributor

is there a preview somewhere for this feature so we can test?

@dstrctrng
Copy link

Check out destructuring/vagrant-shell, just merged a docker demo into the
master branch.

On Fri, Jun 21, 2013 at 6:59 AM, Deni Bertovic notifications@github.comwrote:

is there a preview somewhere for this feature so we can test?


Reply to this email directly or view it on GitHubhttps://github.com//issues/404#issuecomment-19817282
.

@mrjcleaver
Copy link

Is this still being worked on?

From what I gather, vagrant-shell looks like a way to let any set of shell scripts implement the vagrant provisioning interface. It does not have specifics to allow Vagrant to use Docker's LXCs as the containers.

https://github.com/philspitler/vagrant-docker is interesting but I note no work done in the last couple of months.

Martin.

@dstrctrng
Copy link

Looks at the demos in branch feature/destructuring/demos in vagrant-shell for a docker script/demo

Sent from my mind

On Jul 14, 2013, at 10:49 AM, Martin Cleaver notifications@github.com wrote:

Is this still being worked on?

From what I gather, vagrant-shell looks like a way to let any set of shell scripts implement the vagrant provisioning interface. It does not have specifics to allow Vagrant to use Docker's LXCs as the containers.

https://github.com/philspitler/vagrant-docker is interesting but I note no work done in the last couple of months.

Martin.


Reply to this email directly or view it on GitHub.

@shykes
Copy link
Contributor Author

shykes commented Jul 17, 2013

I would still like to see a dedicated provider. I know there is interest in one, but to my knowledge nobody is actively working on it. Consider this an invitation.

I'm closing this issue, please direct future discussions to the mailing list.

@shykes shykes closed this as completed Jul 17, 2013
@philspitler
Copy link
Contributor

@mrjcleaver I actually forked the repo for vagrant-docker from @destructuring because I was interested in the prospect of a Docker provider for Vagrant. I noticed the documentation seem to have been copied from the AWS EC2 Provider, so I only contributed that documentation pull request.

That said, I am still very interested in the possibilities with this. While I don't have a ton of time to dedicate to a project of this magnitude at the moment, I would love to know if anyone starts working on this and will help in any way I can.

@fgrehm
Copy link
Contributor

fgrehm commented Jul 17, 2013

I'm actually planning to spike on a docker provisioner for vagrant / packer when I have the time ;)

@philspitler
Copy link
Contributor

Do you mean something like this?
http://www.packer.io/intro/getting-started/vagrant.html

Or am I misunderstanding something (this is totally possible as it's pretty late here)?

@fgrehm
Copy link
Contributor

fgrehm commented Jul 17, 2013

Actually this and this

@fgrehm
Copy link
Contributor

fgrehm commented Jul 17, 2013

@philspitler and to be clear, this issue is about this :)

@philspitler
Copy link
Contributor

@fgrehm Got it, thanks @fgrehm

@mrjcleaver
Copy link

Well, I glad this is coming together... but I'm clear as to what :)

Maybe someone could spell it out for me? Are there two separate (maybe both valid?) goals here?

Thanks & please excuse my ignorance!

Martin

@thasmo
Copy link

thasmo commented Oct 13, 2013

Hey there! What's the status on this? Thanks a lot!

@fgrehm
Copy link
Contributor

fgrehm commented Oct 13, 2013

AFAIK there is no one actively working on Docker as a Vagrant provider apart from @destructuring's work on vagrant-shell but I've personally started playing with Docker as a provisioner, so instead on using vagrant to control docker containers, I'm using docker to provision Vagrant VMs with multiple containers. If you are interested on that you can check out the Vocker and Ventriloquist projects

On a side note, a future version of Vagrant (hopefuly the next one :) will also support Docker as a first class provisioner and I'll be submiting a PR to Vagrant's core with Vocker's code after some more testing with the latest release.

I've been keeping an eye on things related to this and as far as I can tell that's it about Vagrant + Docker :)

@thasmo
Copy link

thasmo commented Oct 13, 2013

Nice! Thanks for your reply. I've seen Ventriloquist lately, but didn't have a look at it yet. What I'd like to see is a functionality for Vagrant which would use a single VM for multiple projects. Those projects would run as separate docker containers inside this VM. In other words; every project would have a Vagrantfile which would provision a VM with a configured base box and then use Docker to actually set up the project using a docker/lxc container. Keep up the nice work! :)

@thasmo
Copy link

thasmo commented Oct 13, 2013

Vocker looks interesting. Would it also run a Dockerfile from inside a project's directory?

@fgrehm
Copy link
Contributor

fgrehm commented Oct 13, 2013

Not yet but it is planned :)

@fgrehm
Copy link
Contributor

fgrehm commented Nov 5, 2013

Ok folks, apart from docker provisioners (ventriloquist / vocker), I've just open sourced an experimental provider too: https://github.com/fgrehm/docker-provider.

It has quite a few limitations which I'm pretty sure will be around unless things changes on Docker itself and TBH I think that supporting things like changing volumes / bind mounts and exposed ports after the container has been created is out of scope for docker.

Anyways, I hope someone finds it useful :P

@harryw
Copy link

harryw commented Nov 5, 2013

Thanks @fgrehm that is something I've been wanting to get my hands on! 👍

thaJeztah pushed a commit to thaJeztah/docker that referenced this issue Oct 14, 2019
[19.03 backport] revert controller: Check if IPTables is enabled for arrangeUserFilterRule ENGCORE-1114
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests