Docker docs:

Docker routes container traffic in the nat table, which means that packets are diverted before it reaches the INPUT and OUTPUT chains that ufw uses. Packets are routed before the firewall rules can be applied, effectively ignoring your firewall configuration.

        • qaz@lemmy.worldOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          3 months ago

          It’s okay for simple things, but too simple for anything beyond that, IMO. One important issue is that unlike with Portainer you can’t edit the container in any way without deleting it and configuring it again, which is quite annoying if you just want to change 1 environment variable (GH Issue). Perhaps they will add a quadlet config tool to cockpit sometime in the future.

  • Harbinger01173430@lemmy.worldBanned
    link
    fedilink
    arrow-up
    4
    ·
    3 months ago

    Nat is not security.

    Keep that in mind.

    It’s just a crutch ipv4 has to use because it’s not as powerful as the almighty ipv6

  • grrgyle@slrpnk.net
    link
    fedilink
    arrow-up
    2
    ·
    3 months ago

    If I had a nickel for every database I’ve lost because I let docker broadcast its port on 0.0.0.0 I’d have about 35¢

      • grrgyle@slrpnk.net
        link
        fedilink
        arrow-up
        0
        ·
        3 months ago

        I exposed them because I used the container for local development too. I just kept reseeding every time it got hacked before I figured I should actually look into security.

          • grrgyle@slrpnk.net
            link
            fedilink
            arrow-up
            1
            ·
            3 months ago

            My use case was run a mongodb container on my local, while I run my FE+BE with fast live-reloading outside of a container. Then package it all up in services for docker compose on the remote.

            • Ethan@programming.dev
              link
              fedilink
              English
              arrow-up
              2
              ·
              3 months ago

              Ok… but that doesn’t answer my question. Where are you physically when you’re working on this that people are attacking exposed ports? I’m either at home or in the office, and in either case there’s an external firewall between me and any assholes who want to exploit exposed ports. Are your roommates or coworkers those kinds of assholes? Or are you sitting in a coffee shop or something?

              • grrgyle@slrpnk.net
                link
                fedilink
                arrow-up
                2
                ·
                edit-2
                3 months ago

                This was on a VPS (remote) where I didn’t realise Docker was even capable of punching through UFW. I assumed (incorrectly) that if a port wasn’t reversed proxied in my nginx config, then it would remain on localhost only.

                Just run docker run -p 27017:27017 mongo:latest on a VPS and check the default collections after a few hours and you’ll likely find they’re replaced with a ransom message.

        • MangoPenguin@lemmy.blahaj.zone
          link
          fedilink
          English
          arrow-up
          0
          ·
          edit-2
          3 months ago

          For local access you can use 127.0.0.1:80:80 and it won’t put a hole in your firewall.

          Or if your database is access by another docker container, just put them on the same docker network and access via container name, and you don’t need any port mapping at all.

          • grrgyle@slrpnk.net
            link
            fedilink
            arrow-up
            1
            ·
            3 months ago

            Yeah, I know that now lol, but good idea to spell it out. So what Docker does, which is so confusing when you first discover the behaviour, is it will bind your ports automatically to 0.0.0.0 if all you specify is 27017:27017 as you port (without an IP address prefixing). AKA what the meme is about.

  • dohpaz42@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 months ago

    It’s my understanding that docker uses a lot of fuckery and hackery to do what they do. And IME they don’t seem to care if it breaks things.

    • marcos@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      3 months ago

      To be fair, the largest problem here is that it presents itself as the kind of isolation that would respect firewall rules, not that they don’t respect them.

      People wouldn’t make the same mistake in NixOS, despite it doing exactly the same.

  • cadekat@pawb.social
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    I’ve been playing with systemd-nspawn for my containers recently, and I’ve been enjoying it!

  • purplemonkeymad@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    Well yea ofc it works like that, the services are not on the same network, so the packets need to be sent onto another adapter. That means either nat or forwarding tables.

    Now if that was a good design of docker is another question.

  • steventhedev@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    You’re forgetting the part where they had an option to disable this fuckery, and then proceeded to move it twice - exposing containers to everyone by default.

    I had to clean up compromised services twice because of it.

  • jwt@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    3 months ago

    Somehow I think that’s on ufw not docker. A firewall shouldn’t depend on applications playing by their rules.

    • qaz@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      3 months ago

      ufw just manages iptables rules, if docker overrides those it’s on them IMO

      • jwt@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        3 months ago

        Feels weird that an application is allowed to override iptables though. I get that when it’s installed with root everything’s off the table, but still…

  • skuzz@discuss.tchncs.de
    link
    fedilink
    arrow-up
    0
    arrow-down
    1
    ·
    3 months ago

    For all the raving about podman, it’s dumb too. I’ve seen multiple container networks stupidly route traffic across each other when they shouldn’t. Yay services kept running, but it defeats the purpose. Networking should be so hard that it doesn’t work unless it is configured correctly.