Live data from Hacker News

Awesome Docker Compose Examples

github.com

71–80 of 85 posts

Re: Awesome Docker Compose Examples

#71
post #67
post #62

I think I’ve asked this question before but I really don’t understand why there is no managed docker compose hosting solution. I think Swarm did that, but I believe they stopped? Every project I worked on used compose locally, but had to transpose to some k8s/nomad setup in production. I’d love to just run ‘docker compose deploy’ or publish or whatever and it just gets deployed to the cloud + load balancing and autos…

It's not exactly what you're asking for, but https://fly.io > is pretty neat. It's easy to get going and will deploy any docker images you want with a bit of their config added. As for AWS ECS mentioned in the other reply -- it's great if you ever get it working, but it is a nightmare to learn and use.

Docker Compose cannot currently be deployed on fly.io: https://community.fly.io/t/deploy-with-docker-compose-yaml/4... .

Unfortunately, there's a huge gap between "single container" and "multiple, co-dependent containers". It's a far cry between services hosting a single container and ones offering to host entire stacks.

Re: Awesome Docker Compose Examples

#72
post #62

I think I’ve asked this question before but I really don’t understand why there is no managed docker compose hosting solution. I think Swarm did that, but I believe they stopped? Every project I worked on used compose locally, but had to transpose to some k8s/nomad setup in production. I’d love to just run ‘docker compose deploy’ or publish or whatever and it just gets deployed to the cloud + load balancing and autos…

You can do something like this with Bunnyshell (bunnyshell.com) It imports your docker-compose.yml and deploys to k8s. It has CLI and web UI.

Re: Awesome Docker Compose Examples

#73
post #47

Earlier quoted context omitted.

> but it is amazing to me how much black arts still exists for what has become a cornerstone of modern deployment. What?! Unless you are using complicated networking, docker is simple. Dockerfiles are essentially just annoying-syntax shell scripts. We have plenty of black arts in computing. Docker isn't one of them.

So, am I still supposed to specify UID and GID? Should I be using Alpine or Debian? How do I handle loading certificates? Should I use an override config for development? In this thread, someone was indicating that the naive volume option does not work over SSH. Also in this thread was a request to pin by tag and not hash. Do I still need to worry about Docker blowing a hole in iptables? Maybe not black magic, but th…

> So, am I still supposed to specify UID and GID?

If you run your container as a non-root user and create a user without setting a UID / GID it'll default to 1000:1000, so unless your Docker host's user isn't 1000:1000 then things work out of the box. A lot of this is general Linux knowledge around user / file permissions, not so much Docker.

> Should I be using Alpine or Debian?

Debian, no contest in my opinion.

> How do I handle loading certificates?

You can volume mount them or deal with SSL certificates in a way where Docker isn't involved such as running nginx on your Docker host directly or putting a load balancer in front of your app and handling SSL there.

> Should I use an override config for development?

You can use the same docker-compose.yml file in all environments and tweak things with environment variables. The compose file supports variable interpolation. Docker Compose profiles also let you control which services to run in each environment, it's even configurable by a single env variable.

> Do I still need to worry about Docker blowing a hole in iptables?

If you use -p 8000:8000, yes this will publish the port in a way where the outside world can access it. Likewise without Docker if you edit iptables to allow that port it will too. I wouldn't classify this as blowing a hole in iptables. This is "user configured application to make a port open to the world".

> Maybe not black magic, but there are a lot of subtle optimizations for which there is much conflicting guidance.

In the end my example apps address most of these issues for you. You're on your own with certificates since that varies on your deployment, but everything else is fully set up and ready to go and it protects yourself from blowing a hole in iptables since it only publishes the port to localhost by default, not 0.0.0.0. This would let nginx or another web server access it directly on your Docker host but no one else.

Re: Awesome Docker Compose Examples

#74
post #68
post #6

There's a lot of "tool" selections in that repo. If anyone is looking for ready to go web app examples aimed at both development and production with Docker Compose, I maintain: - https://github.com/nickjj/docker-flask-example - https://github.com/nickjj/docker-rails-example - https://github.com/nickjj/docker-django-example - https://github.com/nickjj/docker-node-example - https://github.com/nickjj/docker-phoenix-exam…

Awesome repos, starred. Do you have any preferences for next steps, such as deploy/management? And if you’ve seen it, what do you you think of https://github.com/mrsked/mrsk ?

Thanks.

Yep I've seen mrsk and even briefly chatted with DHH about it a day or 2 after he open sourced it.

I have mixed feelings:

On one hand I think it's fantastic Rails is starting to take on deployment officially. This is going to lead things to a better place in the long run. Generally speaking DHH has a really good track record for making things that feel good to use.

On the other hand, I think the project is trying to reinvent too many things that already exist and doesn't account for Docker Compose. For example, for literally the last 7 years I've been deploying any Dockerized web application with Docker Compose to 1 or more servers with about 15-20 lines of YAML using Ansible to set up the server and git to deploy the code. It doesn't matter if it's Rails, Flask, Django, Phoenix, Node, Go or whatever. It's all the same. Those 20 lines also include everything from taking a blank slate Debian / Ubuntu box to production ready, complete with self managed system updates, locking down SSH, iptables, various server configurations / optimizations, nginx, HTTPS, database backups, sane logging and everything else you'd expect.

I don't have anything ready yet but I've been slowly working on https://nickjanetakis.com/courses/deploy-to-production to assemble all of this into a course.

Re: Awesome Docker Compose Examples

#75
post #58
post #6

There's a lot of "tool" selections in that repo. If anyone is looking for ready to go web app examples aimed at both development and production with Docker Compose, I maintain: - https://github.com/nickjj/docker-flask-example - https://github.com/nickjj/docker-rails-example - https://github.com/nickjj/docker-django-example - https://github.com/nickjj/docker-node-example - https://github.com/nickjj/docker-phoenix-exam…

Does this start rails app and postgre db on the same server?

By default yes but you can change a single environment variable to not run Postgres or Redis through Docker Compose. You can also very easily choose to run Puma and Sidekiq on different servers. It leverages Docker Compose v2 profiles.

I'd suggest watching and reading: https://nickjanetakis.com/blog/a-guide-for-running-rails-in-...

It's a full end to end walk through of the example Rails app and how it all works when it comes to Docker and Docker Compose. I just recorded it a month ago, it covers everything with up to date info vs the code in the repo.

Re: Awesome Docker Compose Examples

#76
post #6

There's a lot of "tool" selections in that repo. If anyone is looking for ready to go web app examples aimed at both development and production with Docker Compose, I maintain: - https://github.com/nickjj/docker-flask-example - https://github.com/nickjj/docker-rails-example - https://github.com/nickjj/docker-django-example - https://github.com/nickjj/docker-node-example - https://github.com/nickjj/docker-phoenix-exam…

Any golang?

Nope, I haven't run any Go code in production that was running in Docker.

Go's ecosystem is also pretty fragmented so it would be difficult to create a solution that lots of folk would be happy with. I get the impression most folks who use Go want to pick everything themselves (not a bad thing, just something I noticed). Plus I'm only 1 person doing this in my free time with no income sources attached to these projects, I don't have the capacity.

With that said, most of the apps are very similar when it comes to the Docker bits. You could take any of the examples and replace XXX with Go. I'd suggest basing it off the Phoenix example because that one covers using a 2nd Docker build stage to create a release. With Go being able to compile a self-contained binary that pattern of using a build stage to copy that over would be similar.

Re: Awesome Docker Compose Examples

#77
post #35
post #6

There's a lot of "tool" selections in that repo. If anyone is looking for ready to go web app examples aimed at both development and production with Docker Compose, I maintain: - https://github.com/nickjj/docker-flask-example - https://github.com/nickjj/docker-rails-example - https://github.com/nickjj/docker-django-example - https://github.com/nickjj/docker-node-example - https://github.com/nickjj/docker-phoenix-exam…

Taking a quick look and nothing I saw manages ssl - do you even package that or do you have that as entirely different steps?

It's not included with these projects, as someone else mentioned in a reply to you, it can be handled in a number of different spots.

For example, a load balancer running 1 level above your server or perhaps nginx running directly on your Docker host without Docker.

A while back I wrote up why I prefer running nginx outside of Docker at: https://nickjanetakis.com/blog/why-i-prefer-running-nginx-on...

Re: Awesome Docker Compose Examples

#78

FWIW the standard now says the file should be called "compose.yaml"; "docker-compose.yaml" is supported but deprecated

That is a big change.

After June 2023 Docker Compose v1 will officially no longer be supported. I probably won't switch right then and there to the new filename but that is at least one ball moving in the right direction to switch over to the new file.

The other problem is more of a human one. There's 7+ years worth of blog posts, videos and documentation referencing docker-compose.yml. Having all of those become invalid is a big price to pay when onboarding new folks to Docker. When learning something new, it stinks when you find conflicting or different information all over the place.

Long story short, I will switch to using it but it's going to take time.

Re: Awesome Docker Compose Examples

#79
post #55
post #50

Earlier quoted context omitted.

Ambitious decision. As if docket-compose is the only tool that uses the word compose, and there is no other extremely common tool, that uses for configuration, for instance, files like composer.json and composer.lock.

I’m on my phone and haven’t double checked this, but from my understanding, I believe it’s part of an effort to encourage compatibility with other tools like podman. The ambiguity is somewhat intentional, as an active decision to separate the implementation name from the configuration standard.

composer.json is from PHP. Config file for package manage (almost universal).

So it will be even bigger pain in the keyboard to write them :(

Re: Awesome Docker Compose Examples

#80
post #67

Earlier quoted context omitted.

It's not exactly what you're asking for, but https://fly.io > is pretty neat. It's easy to get going and will deploy any docker images you want with a bit of their config added. As for AWS ECS mentioned in the other reply -- it's great if you ever get it working, but it is a nightmare to learn and use.

Docker Compose cannot currently be deployed on fly.io: https://community.fly.io/t/deploy-with-docker-compose-yaml/4... . Unfortunately, there's a huge gap between "single container" and "multiple, co-dependent containers". It's a far cry between services hosting a single container and ones offering to host entire stacks.

Right, I wasn't suggesting you could deploy with Docker Compose on fly.io. Hence why I prefaced my suggestion with "It's not exactly what you're asking for..."

And I think you're exaggerating the "huge gap" there. Fly.io can run multiple docker containers for you. Their docs are great so it wouldn't take much effort to learn how to create an equivalent or better setup that covers everything Docker Compose does (and more).

Post reply on HN