Live data from Hacker News

Ask HN: How do you use Docker in production?

news.ycombinator.com

151–157 of 157 posts

Re: Ask HN: How do you use Docker in production?

#151

Docker explicitly violates the principles of the Twelve-Factor App. Docker apps don’t rely on any external environment. In fact, Docker demands that you store all config values, dependencies, everything inside of the container itself. Apps communicate with the rest of the world via ports and via Docker itself. The trade-off is that apps become a little bit bulkier (though not significantly), but the benefit is apps b…

> In fact, Docker demands that you store all config values, dependencies, everything inside of the container itself.

No it doesn't. In fact, parameterised containers are a thing that many people encourage. This is where you specify configuration when you run the container instead of when you build it. This can done using arguments to the CMD, environment variables, config volumes, or using something like etcd.

Re: Ask HN: How do you use Docker in production?

#152
post #124

Earlier quoted context omitted.

> They advertise themselves into etcd, and any dependencies are pulled from etcd. That means that the Django app gets the addresses for the PostgreSQL and Redis servers from etcd, and connects that way. If these values change, each container restarts itself as needed. Could you explain a bit more how that works?

Take Postgres for example. I use the official Docker image, and run it via a fleet .service file, having it store its data in a Docker data-only container, also launched from a fleet unit file. Finally, there's a third unit file that runs a slightly customized version of the docker-register image from CoreOS's polvi. This Dockerized app polls the Docker socket every 10s or so to get the IP and port information for th…

"If these values ever differ from what's currently in etcd, then my Django app will send a signal to cause uwsgi to gracefully restart the Django app, so that it can reload itself with the new configuration"

You could probably avoid the restart/reload by using skydns (https://github.com/skynetservices/skydns), it is a local dns service built on top of values in etcd. You can configure your django app to access the other service containers by dns name and it will be translated to the correct ip all the time.

Re: Ask HN: How do you use Docker in production?

#153

Docker, CoreOS, fleet, and etcd have completely changed how I build projects. It's made me much more productive. I'm working on Strata, which is a building management & commissioning system for property owners of high-rise smart buildings. It's currently deployed in a single building in downtown Toronto, and it's pulling in data from thousands of devices, and presenting it in real-time via an API and a dashboard. So…

I'd love to get in touch and have a chat with you on what you're doing, I'm working on similar stuff but don't see much HVAC/energy around HN. Could you drop me a line (contact details in my profile)? Thanks!

Re: Ask HN: How do you use Docker in production?

#154
post #89

Earlier quoted context omitted.

ok thanks. I have several app servers and I take them out of nginx server list, stop it gracefully, git pull and configure (slow, I want to get rid of this step), put it back in nginx servers, move onto the next one. tedious, although my whole deploy-to-all-servers is a single command.

Yeah, that sounds pretty tedious, but I guess it could still be automated (but somewhat tricky). Once CoreOS becomes more stable, we're looking to move to it. The idea is then to use `etcd` to feed the load balancer (probably Nginx) with the appserver pool. That way you can easily add new servers and decommission old ones.

We automated this pretty trivially at my last job using Fabric[0]. All we had to do was cycle through a list of servers and apply the remove from LB, update, add to LB steps. Removing from the LB should simply block until connections drain (or some reasonable timeout). It makes deploys take longer for sure, but avoiding the inevitable killing of user connections was worth it.

[0] http://www.fabfile.org/

Re: Ask HN: How do you use Docker in production?

#155
post #89

Earlier quoted context omitted.

Yeah, that sounds pretty tedious, but I guess it could still be automated (but somewhat tricky). Once CoreOS becomes more stable, we're looking to move to it. The idea is then to use `etcd` to feed the load balancer (probably Nginx) with the appserver pool. That way you can easily add new servers and decommission old ones.

We automated this pretty trivially at my last job using Fabric[0]. All we had to do was cycle through a list of servers and apply the remove from LB, update, add to LB steps. Removing from the LB should simply block until connections drain (or some reasonable timeout). It makes deploys take longer for sure, but avoiding the inevitable killing of user connections was worth it. [0] http://www.fabfile.org/

that's exactly what I'm doing, but using ansible. I used to do it with fabric before that.

its slow, but I go have a cup of tea while it works.

Re: Ask HN: How do you use Docker in production?

#156
post #89

Earlier quoted context omitted.

Yeah, that sounds pretty tedious, but I guess it could still be automated (but somewhat tricky). Once CoreOS becomes more stable, we're looking to move to it. The idea is then to use `etcd` to feed the load balancer (probably Nginx) with the appserver pool. That way you can easily add new servers and decommission old ones.

We automated this pretty trivially at my last job using Fabric[0]. All we had to do was cycle through a list of servers and apply the remove from LB, update, add to LB steps. Removing from the LB should simply block until connections drain (or some reasonable timeout). It makes deploys take longer for sure, but avoiding the inevitable killing of user connections was worth it. [0] http://www.fabfile.org/

I will add that if you're using Docker (which we weren't) it might be easier to deploy a new set of Docker containers with updated code and just throw away the old ones.

Re: Ask HN: How do you use Docker in production?

#157
Created own tool for this: https://mcloud.io.

Cool thing about this, you don't need to change anything in config when deploying. + it follows docker's best practices like one process per container.

Already can't imagine I will deploy something without it. It's OpenSource (MIT, contributions are welcome) and current functionality will stay free forever.

Hope will be useful for somebody, not only for our team.

Post reply on HN