7 ms·
Awesome Docker Compose Examples
- sneak 4y agoSecurity note: specifying no version, or a version tag (and not an @-hash) in the docker image name allows DockerHub or the image publisher to replace the code underneath you on container restarts (ie RCE), as they are not cryptographically assured.
- nandur 4y agoYou would have to down (remove) the container to change the image, if the image is present with the tag if wont get force pulled (singular node scenario), unless you have that image locally, heck this is not that straightforward. I like the idea of using digests though, using both head explodes, explicitly, another head explosion may prevent some headaches.
- deleted 4y ago[deleted]
- vorpalhex 4y ago...and you'd have to do that for every single security update for every single service that you run. If you need that level of security that might be appropriate, but most users need security patches more than they need to be concerned with a novel attack that requires DockerHub to intend to RCE them.
- fbdab103 4y agoWhile the track record of security in the industry is pretty laughable, I do like to delude myself that things are improving. How many RCEs are discovered per year in baseline Debian/Ubuntu? Seems far more likely that security holes are in the library/application code layered on-top of an image.
- capableweb 4y ago> novel attack Harmful code pushed into large software repositories masquerade as something else is not novel and is starting to happen more and more.
- password4321 4y agoSilently replacing version tags in the container registry is currently one of my biggest pet peeves.
- deathanatos 4y agoUsing @-hashes doesn't assure you of not getting pwned the same way here. How are you getting the @-hash, if not just looking at what the tag points to? Sure, the image is changing now only at intentional times (as opposed to just any restart), but you're still not getting an assurance that a "trusted" upstream isn't going to RCE you. Security updates & patches come out with such frequency that the number of windows of opportunity are still plentiful. Better advice would be to use tags, but to vendor the images somewhere and point at the vendored copies. You still get the "doesn't change on random restart", you have an idea of what version you're on that the hash doesn't tell you, you don't have to deal with Docker hashes being the weird AF things they are (e.g., you side-step the confusion that library/foo@sha256:XXXXX == vendored/foo@sha256:YYYYY), and you're more respectful of upstream's bandwidth and you're not dependent on their reliability concerns. (And frankly, given how poorly most of the industry handles security updates, I'd argue that sitting on a very loose tag might be more secure overall, because then security patches might be happening at random times, as opposed to not at all. The trade-off of the RCE is worth it, and there are ways for upstreams to mitigate the risk there, centrally. Most companies struggle with just vendoring, and few get to actually keeping that up-to-date, IME due to a lack of willingness to apply the necessary resources to the problem.)
- capableweb 4y ago> Using @-hashes doesn't assure you of not getting pwned the same way here It does, changes to the image could be pushed to "latest" or a specific tag, but the hash cannot change, once you've established that a specific hash is secure, it'll remain secure (or rather, as secure as you first established it as).
- AgentK20 4y agoI think the parent comments point was that it’s difficult, if not impossible, to verify the security of even a particular hash. It’s still vulnerable to the same dependency chain vulnerabilities as pinning to latest, but instead locking in a particular version and _hoping_ that it wasn’t pwned. Additionally, you are then not getting any exploit fixes that may be included in newer versions, so even if there was a vulnerability you are now stuck with it until you decide to manually update. To be honest if you’re that concerned with dependency attacks like that then you should just be hosting your own image registry and building your images yourself, and then only being vulnerable to dependency attacks within the OS distributions and such.
- nickjj 4y agoThere'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-example About once a week or so I update them to their latest versions for everything. The examples use a combination of services for each tech stack such as web + worker + postgres + redis + esbuild + tailwind. The Rails example is set up for Hotwire and runs Action Cable as a dedicated service along with Sidekiq where as the Flask and Django examples use Celery as a worker. You can easily swap things out since the examples are starter projects that you can clone + rename (they all come with a rename script), you're meant to customize them to build your app on top of.
- decide1000 4y agoThanks! I will use this.
- fbdab103 4y agoThis looks great. Definitely a few idioms I will have to explore further. I can use Docker in a basic sense, but it is amazing to me how much black arts still exists for what has become a cornerstone of modern deployment. Lots of conflicting/dated advice about best practices. Unsure which advice is still required/applies to podman, etc.
- sneak 4y ago> 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.
- fbdab103 4y agoSo, 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 there are a lot of subtle optimizations for which there is much conflicting guidance.
- EnigmaCurry 4y agoNice collection, although I don't really like binding volumes to host directories, because then you can't really use docker over SSH. I'm working on my own similar project here that exclusively uses docker named volumes: https://github.com/enigmaCurry/d.rymcg.tech https://github.com/enigmaCurry/d.rymcg.tech
- sevg 4y agoWhat do you mean by "can't really use docker over SSH"? I'm not sure what that means, or how it's related to bind mounts.
- EnigmaCurry 4y agoI mean using a remote Docker context over SSH, where I run `docker` commands on my laptop, but it runs the containers on a remote Docker server. My laptop does not run the docker daemon, so its just a client. If you tell me to run docker run -v ${HOME}/stuff:/stuff alpine It will mount /home/stuff on the server, not my own home directory on my laptop. I would have to run another process that rsync's my local /home/stuff to the server.
- andix 4y agoJust run docker compose on the remote machine (and copy the compose file with scp). I don’t see a lot of benefits if you run docker compose on another machine than the docker daemon. You can even automate it with ansible, terraform, or similar, if you like it neat. Or just go with k8s if you need a more complex setup.
- EnigmaCurry 4y agoThat is an entirely valid approach, but this way it feels like the server requires more maintainance. I can destroy a docker named volume through the lifecycle of the container. But I cant delete a system directory. (edit: I mean using `docker compose down -v` it deletes a named volume, but not a system directory) Also, its really nice to be able to use `docker context use SERVER_NAME` so I can switch contexts (servers) very easily.
- SergeAx 4y ago> - TZ=Europe/Berlin OMG, why?! It is even had a daylight savings!
- gonzo41 4y agoNice examples. I personally really love compose. For all the complexity in the container space it really nails down a fanatic experience.
- Terretta 4y ago> I personally really love compose. For all the complexity in the container space it really nails down a fanatic experience. Fanatics love docker, for sure. It's… fantastic!
- gonzo41 4y agoLol, I didn't catch that. You know what I mean.
- glenngillen 4y agoMight not totally be a coincidence that it started life as an independent thing to give Docker a better experience, that Docker then acquired/acqui-hired.
- throwawaaarrgh 4y agoFWIW the standard now says the file should be called "compose.yaml"; "docker-compose.yaml" is supported but deprecated
- krick 4y agoAmbitious 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.
- guffins 4y agoI’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.
- przemo_li 4y agocomposer.json is from PHP. Config file for package manage (almost universal). So it will be even bigger pain in the keyboard to write them :(
- Too 4y agoEqually confusing and often misunderstood is that the latest version of a compose file should not have a version field at all! It is a blend of v2, v3 and any newly added attributes (v3 some times supported less than v2), that is now called the compose spec. Implementations are supposed to do feature detection based on what attributes are used in the file. Make sure your docker compose is new enough, otherwise it thinks absence of version field means v1!
- throwawaaarrgh 4y agoYeah I was gonna complain about this but honestly I don't even know what the hell they're doing with the version field anymore. I suspect it's because they want to force you to upgrade because otherwise they may have to support legacy longer.
- jrm4 4y agoGiven that these are a lot of homelab examples; this is great. I use a bunch of these and plan to use more. But part of me still makes me think about what I think might be the gold standard of self-hosted, cloud-like things, and that's Syncthing? As in, all of these things should try to figure out how to be like syncthing?
- perlwle 4y agorepos sitting in my Bookmarks. * https://github.com/docker/awesome-compose https://github.com/docker/awesome-compose * https://github.com/PostHog/posthog https://github.com/PostHog/posthog * https://github.com/growthbook/growthbook https://github.com/growthbook/growthbook * https://github.com/fleetdm/fleet https://github.com/fleetdm/fleet Supposedly, One can search github using `language:typescript filename:docker-compose.yml stars:>1000` but it's not working for me somehow.
- kalev 4y agoI 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 autoscaling. What am I missing?
- mise_en_place 4y agoYou can use ECS for that.
- neodon 4y agoIt's not exactly what you're asking for, but <https://fly.io 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.
- diarrhea 4y agoDocker Compose cannot currently be deployed on fly.io: https://community.fly.io/t/deploy-with-docker-compose-yaml/4566/2 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.
- neodon 4y agoRight, 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).
- LeBit 4y agoI've stopped using Docker Compose and only use Kubernetes. Even when working locally. I don't want the impedence mismatch of working locally with Docker and remotely with K8s. That being said, K8s IS harder to setup initially. Having to setup an NFS share locally to be able to properly mount data in a PV is suboptimal.