News for hackers. Stuff that matters.
Re:Ask HN: As a web developer, do I have to know what Docker... by sd8dgf8ds8g8dsg on Thursday October 26, 2017 @01:59AM (#15556711)
Using docker can greatly improve your development situation. For example, you can use docker to define the full environment needed to run your web app, meaning you can have another dev running it with "docker run", and not needing to install any local dependencies, as everything (web server, node etc) is contained inside the docker container. This turns out also be useful for your future self, when you in 2 years from now are having troubles re-creating the environment needed for running your service.

Docker orchestrate can further improve your development situation, in which you can use it to define and test out multiple virtual servers on your laptop, such as the database, the file server and the web server.

Re:Ask HN: As a web developer, do I have to know what Docker... by stephenr on Thursday October 26, 2017 @02:27AM (#15556825)
Quite honestly Vagrant will do all of that for development.
Re:Ask HN: As a web developer, do I have to know what Docker... by mickeyp on Thursday October 26, 2017 @03:54AM (#15557124)
Yes, with the caveat that if you already use a hypervisor for your main dev environment then running another inside it with Vagrant's default VBox setup is likely to either be very slow or not work at all.

Docker will also layer and cache each command greatly speeding up the "build&test" cycle of writing and running Docker containers. With Vagrant you're re-running everything every time.

Furthermore, you can actually use Docker with Vagrant also nowadays.

Re:Ask HN: As a web developer, do I have to know what Docker... by stephenr on Thursday October 26, 2017 @04:26AM (#15557242)
This sounds like a rare scenario, much more common these days I believe would be a non-Linux host, with a Linux "guest" server environment.

If you want to use Docker, you're then automatically using a hypervisor anyway.

> With Vagrant you're re-running everything every time.

Are you talking about the time to provision a non-created environment?

On a clean install, sure, that might take a while if your base-box doesn't have the dependencies you require - but most developers wouldn't often need to re-build their Vagrant environment for a project from scratch (i.e. vagrant destroy is not likely to be a common task). And that whole situation is moot if you use or build a more appropriate base box.

Re:Ask HN: As a web developer, do I have to know what Docker... by mickeyp on Thursday October 26, 2017 @09:39AM (#15558668)
Is it that uncommon? Mac users using a hypervisor? Windows using running Linux in a Virtualbox? That's pretty common in corporate environments...

I am talking about rebuilding the Vagrant image every time you change it - as you are wont to do during the initial step of creating it. Sure, once it's written (by someone who has to spend a fair amount of elapsed time doing trial-and-error tweaks) then you don't have to re-cycle the image. On the other hand, that too can result in people using stale images over time as the configuration drifts.

Re:Ask HN: As a web developer, do I have to know what Docker... by stephenr on Thursday October 26, 2017 @09:56AM (#15558805)
> Mac users using a hypervisor? Windows using running Linux in a Virtualbox?

Vagrant works natively on Macs and Windows, unlike Docker. There is zero reason to run it inside an already virtualised environment on those machines.

> I am talking about rebuilding the Vagrant image every time you change it

You know you don't need to destroy the vagrant environment to re-run the provisioning scripts, if something changes.. right?

> Sure, once it's written (by someone who has to spend a fair amount of elapsed time doing trial-and-error tweaks)

With the minor exception of a few Vagrant specific optimisations (a `vagrant` user with the predefined SSH key & passwordless sudo, for example) during base-box building, literally nothing in a Vagrant provisioning environment needs to be specific to Vagrant.

Also - if you're building base-boxes, it's probably worthwhile forking an existing project that targets your Distro/OS of choice and customising from there.

> On the other hand, that too can result in people using stale images over time as the configuration drifts.

Why? If it's a small change, just set the provisioner to `run: "always"` and it will run on every up. Assuming the changes (i.e. new/updated deps, or config files being copied) are small, it'll be almost instantaneous.

From everything you've said, I'm very curious how you use Vagrant (if at all). It isn't intended to be used like Docker, where you package up an entire image completely ready to use with 0 cycles needed to configure anything, and an update means a new image.

Re:Ask HN: As a web developer, do I have to know what Docker... by sumedh on Thursday October 26, 2017 @03:38AM (#15557046)
Setting up containers is ridiculously fast compared to VMs.
Re:Ask HN: As a web developer, do I have to know what Docker... by stephenr on Thursday October 26, 2017 @04:21AM (#15557212)
What do you mean by "setting up". Are you talking about the work to provision a working target environment (i.e. what the VM/Container runs) or are you talking about the literal time for the environment to start?
Re:Ask HN: As a web developer, do I have to know what Docker... by viraptor on Thursday October 26, 2017 @05:13AM (#15557421)
Containers help with both. No full-system boot delay helps. Cached layers help. Not dealing with vm-specific kernel modules helps. Fast non-nfs volumes shared with the host help.

There are speed benefits for containers all over the place - both in time spent dealing with the environment and in actual execution.

Re:Ask HN: As a web developer, do I have to know what Docker... by stephenr on Thursday October 26, 2017 @05:31AM (#15557486)
> No full-system boot delay helps

I just cold-booted a Vagrant VM, which is configured to check for new base-box versions (i.e. a network delay that can be disabled).

    time vagrant up
    ...
    real    0m39.698s
    user    0m11.989s
    sys     0m5.490s
If your argument about tooling is around performance and the "slow" one takes just 40 seconds to start, I think you need to clarify how often you expect to be starting this tool in a day.

> Cached layers help.

Helps what, exactly?

> Not dealing with vm-specific kernel modules helps.

I don't even know what you're talking about here. Do you mean you need to have a hypervisor kernel module? What exactly do you need to "deal with"?

> Fast non-nfs volumes shared with the host help.

I've never once used an NFS volume in a Vagrant guest. In case you weren't aware, Vagrant is not limited to using VirtualBox.

> There are speed benefits for containers all over the place - both in time spent dealing with the environment and in actual execution.

You haven't actually identify any environment issues you need to "deal with", just said "X helps".

Re:Ask HN: As a web developer, do I have to know what Docker... by viraptor on Thursday October 26, 2017 @06:51AM (#15557758)
Some context then. The happy path startup cost (environment is already prepared) matters to devs who never deal with the environment itself. If you're dealing with frontend only - maybe that's you most of the time, and you only see the 40s maybe once a day.

But there are other costs. Someone deals with updates, with adding new functionality, with debugging issues. I spend most of my day recently waiting for puppet runs in vagrant/vbox. It's 10+ min for a full run. Then I make more changes - sometimes an incremental provision is enough, sometimes I need a full rebuild. On the other hand, if the environment was built with docker layers, I'd have much less waiting to do, because the caching of partial build/layer is integrated. Over a whole day, that's not insignificant time saving.

And sure, vagrant has multiple backend. I'm using vbox, and so does almost every developer using vagrant. It's the only free one. (Apart from the docker backend)

Re:Ask HN: As a web developer, do I have to know what Docker... by stephenr on Thursday October 26, 2017 @08:15AM (#15558162)
That is literally what the concept of base boxes is for.

Build your own base box with whatever prerequisites you have baked in. It's still a 10 minute puppet run if that's how long your provisioning takes, but that happens once, and then you distribute the box. While you can just use a base distro box, for large/complex setups it's not always the best approach.

Re:Ask HN: As a web developer, do I have to know what Docker... by viraptor on Thursday October 26, 2017 @10:44PM (#15565289)
The idea of the base boxes is there, sure. But the ability to configure repositories, make base box of that, install keys, make base box of that, install required told, make base box of that, ... etc. with the mechanism for transparent reuse of the latest cached box you care about is not available on vagrant. And when you're making changes and debugging, it makes all the difference. If vagrant integrated a nice way to do that, the time saving would be amazing.
Re:Ask HN: As a web developer, do I have to know what Docker... by stephenr on Friday October 27, 2017 @01:01AM (#15565829)
You kind of can do that, but it's not a Vagrant feature, so much as a Packer feature.

Most of the Packer builders (e.g. virtualbox, parallels, VMware) support building from scratch (i.e. start with ISO install media and a blank VM disk) OR building from an existing VM.

So you could have a multi-stage Packer build pipeline that iterates step by step.

But I'm still not really sure what your workflow is. My company builds a series of Debian (and for a client, Ubuntu) base boxes. When debugging issues, 99% of time required is checking/fixing inside a running box. Once a solution is found, applying that back to the base box provisioning scripts (or preseed or even the packer config) and testing a build doesn't take that long.

Re:Ask HN: As a web developer, do I have to know what Docker... by sumedh on Thursday October 26, 2017 @09:36AM (#15558649)
How long does it take to setup postgres 9.4 with test datbase and one user for that DB in vagrant?

What is the command/process to do that?

Re:Ask HN: As a web developer, do I have to know what Docker... by stephenr on Thursday October 26, 2017 @10:01AM (#15558851)
What's your config management tool of choice? I assume they will have recipes/etc for basic tasks like that.

Personally I'd just put the call to `apt-get` and then `psql` into a shell script.

Either way, set the provisioner. Either do it in vagrant provisioning, or if that takes to long, build a base box with Packer and put the provisioner there.

Edit: or for a simpler use, look on Vagrantcloud.com and find a base box that has what you want, and run that.

Re:Ask HN: As a web developer, do I have to know what Docker... by turtlebits on Thursday October 26, 2017 @12:46PM (#15560596)
For docker w/ docker-compose, I can get a postgres container in <2 seconds with this definition

  version: "2"
  services:
    database:
      image: postgres
      environment:
        - POSTGRES_PASSWORD=123456
      ports:
        - "5432:5432"

docker-compose up -d 0.59s user 0.14s system 50% cpu 1.462 total

And restarting it takes < 1 second.

Re:Ask HN: As a web developer, do I have to know what Docker... by stephenr on Thursday October 26, 2017 @11:43PM (#15565558)
See: https://news.ycombinator.com/item?id=15565554

You're relying on an existing image. That concept works in Vagrant too.

And if you want quick startup and are already on a Linux host, use vagrant-lxc.

Re:Ask HN: As a web developer, do I have to know what Docker... by sumedh on Thursday October 26, 2017 @06:54PM (#15563961)
Since you did not give a simple one line command I am going to assume its difficult to do that in vagrant.

You dont need to mess with a config management tool when you have docker.

Re:Ask HN: As a web developer, do I have to know what Docker... by stephenr on Thursday October 26, 2017 @11:42PM (#15565554)
If a box provides Postgres it's just `vagrant init vendor/boxname && vagrant up`.

That's what you're relying on with a '1 line command' in docker to give you Postgres: an image that someone else has created.

Whether a Postgres-only box exists in Vagrantcloud is irrelevant, unless your argument is purely on the merits of the pre-made boxes/images third parties have contributed.

Re:Ask HN: As a web developer, do I have to know what Docker... by sumedh on Friday October 27, 2017 @12:46AM (#15565779)
You did not answer how long does it take to do that.
Re:Ask HN: As a web developer, do I have to know what Docker... by stephenr on Friday October 27, 2017 @12:54AM (#15565807)
Most boxes start in ~30s on reasonable hardware. I don't know how long the box will take to download because I don't know what box you might use, what vagrant provider (e.g. parallels boxes are usually a little bigger than vbox ones), what your internet connection speed is.

If your entire decision making process is "I only run things that take two seconds" then I don't think we can have a conversation because honestly I don't even think about the time vagrant takes to start.

My computer does multiple things all at once. It takes longer for my IDE to start and be usable than it does for Vagrant, and funnily enough computers can run multiple processes at once, so this whole "omg 30 seconds is too long to wait" argument doesn't fly for me.

Re:Ask HN: As a web developer, do I have to know what Docker... by sumedh on Friday October 27, 2017 @04:40AM (#15566676)
The setup time is one of the argument, in docker the whole thing takes couple of seconds, you might not appreciate the quick boot up time but lot of others care about that. If you are happy with slow boot up time then you should not migrate to docker but if you want something quick and easy then consider docker.
Re:Ask HN: As a web developer, do I have to know what Docker... by stephenr on Friday October 27, 2017 @04:49AM (#15566710)
> in docker the whole thing takes couple of seconds,

Once you have a running Linux Kernel. I don't use a Linux host OS, so I would still have a delay starting a VM to run Linux, and running a Hypervisor to run containers for a dev environment is too many levels of abstraction for my liking.

> you might not appreciate the quick boot up time but lot of others care about that. If you are happy with slow boot up

Is Docker quicker? Sure. Does that make Vagrant slow? No. Slower does not mean slow.

> but if you want something quick and easy then consider docker.

I prefer things I actually have control over rather than just "quick and easy".

Re:Ask HN: As a web developer, do I have to know what Docker... by sumedh on Friday October 27, 2017 @04:58AM (#15566750)
> Is Docker quicker? Sure.

I rest my case, feel free to yell at kids to get off your lawn.

> Slower does not mean slow.

Whatever makes you happy. If you are happy with vagrant stick to it, nobody is forcing you to use something better.