Live data from Hacker News

Docker Compose best practices for dev and prod

prod.releasehub.com

31–40 of 166 posts

Re: Docker Compose best practices for dev and prod

#32
post #8

Docker is cool and all. Kids these days don’t know anything about Tmux and port 433. Exposing localhost to the internet and getting your internet monitored by your ISP and getting letters in the mail; for hosting movies and Storage services. Lol.

If it's going over port 443, how would your ISP know you're hosting movies? The way ISPs catch you is by seeing that you're connecting to IPs that are known to host content illegally. There's now way for your ISP to know what's going _out_ of your port 443 without breaking TLS.

Your ISP doesn't care about what you're connecting to and accessing, at least not until they get a court order demanding that info.

They care a LOT about what you're serving to other people from their network though as there might be some legal issues directed back at them.

Re: Docker Compose best practices for dev and prod

#34
post #8

Earlier quoted context omitted.

If it's going over port 443, how would your ISP know you're hosting movies? The way ISPs catch you is by seeing that you're connecting to IPs that are known to host content illegally. There's now way for your ISP to know what's going _out_ of your port 443 without breaking TLS.

Your ISP doesn't care about what you're connecting to and accessing, at least not until they get a court order demanding that info. They care a LOT about what you're serving to other people from their network though as there might be some legal issues directed back at them.

Your ISP may care about what your connecting to very much, and are prepared to sell it to the highest bidder.

https://arstechnica.com/information-technology/2015/03/atts-...

Re: Docker Compose best practices for dev and prod

#35

Is there a "proper" way to have per host configs? I have a setup where I need to set "hostname: " depending on the system I'm on and right now I'm having to resort to using "docker compose -f compose. .yml up -d" where compose. .yml extends compose.yml

docker compose automatically looks for .env file with the format key=value and will auto populate variables in the docker-compose.yml with matches.

Ex:

docker-compose.yml:

hostname: ${HOSTNAME}

.env:

HOSTNAME=foo.bar.com

Re: Docker Compose best practices for dev and prod

#36
post #17
post #13

Earlier quoted context omitted.

You can accomplish the same thing using environment variables. You can pass them in at build time or deploy time. `ENVIRONMENT=dev docker-compose up` or `docker-compose build --build-arg ENVIRONMENT=dev` and in your case maybe you write some function `find_answer() { something-async ... }; ENVIRONMENT=$(find_answer) docker-compose ...` You can also read in .env files... Which in my opinion is cleaner since you can ch…

It's a simple example, maybe too simple to get the point. What I want is to conditionally set things on a yaml file. If you have ever used a templating language, you know this problem services: redis: ... {{ if some_condition }} volumes: bla bla {{ end if }} {{ if some_other_condition }} another_service: ... {{ end if }} volumes: {{ for volume in volumes }} - ... {{ end for }}

no haha I get the point but it's just another example I see someone over engineering a problem where it should be declarative. In what use case would you dynamically provision some arbitrary n number of volumes without knowing the path names to them? for volumes why wouldn't you just use "volume_name:/some/path" ... "another_volume:/another/path" and let docker manage the volume for you? you're going to end up writing in a different file "/some/path,/another/path" so why not just put it in the compose file?Also why wouldn't you just mount the root path and put n paths inside of them instead of making them all volumes? I'm struggling to see that you're use case actually needs such a feature and you're solving a problem for something that's actually broken somewhere else. you're adding some virtual layer that's making things harder to manage or understand because you don't understand all the features of docker compose technology instead of fixing the root of the issue. I'm not convinced that you're "feature" is necessary.

Re: Docker Compose best practices for dev and prod

#37

Docker is cool and all. Kids these days don’t know anything about Tmux and port 433. Exposing localhost to the internet and getting your internet monitored by your ISP and getting letters in the mail; for hosting movies and Storage services. Lol.

What does tmux have to do with anything?

Re: Docker Compose best practices for dev and prod

#38

If you don't use the same Docker Compose file for Production, don't use it for Development. Your two different systems will diverge in behavior, leading you to troubleshoot two separate sets of problems, and testing being unreliable, defeating the whole "it just runs everywhere" premise. Docker Compose is fine for running smoke tests/unit tests, but if Dev and Prod run differently, there's really no point to using Do…

That is an absurdly black-and-white view.

Re: Docker Compose best practices for dev and prod

#39
The article is titled "for dev and prod" (emphasis on the latter), yet the very first suggestion is to bind-mount your source outside the container so you can mess with it at any time? How is this good advice for production?! (Update: this is indeed great advice for development, and it's actually in a sub-section dedicated to that! My bad.)

Update: reading comprehension, it's a thing! :) Thanks chrsig for pointing out that this is under an appropriate sub-heading. D'oh!

Re: Docker Compose best practices for dev and prod

#40

I recently learned that moving the compose file around and running commands on it with it in different directories puts things into a bad state. This is because it apparently tags images and containers with context on where the compose file was run from. However, you can negate this by always passing in a custom project name with -p.

There's something about that decision that violates my mental model. Feels similar to a referential transparency issue: the state of the system should be the same regardless of the name of the directory something lives in.
Post reply on HN