Hi, I recently acquired a pretty solid VPS for a good price, and right now I use it to run Caddy for two personal sites. When I moved to Lemmy I found about this awesome community and it got me really interested in selfhosting. I won’t be asking for tips on what to selfhost (but feel free to add what you use), there’s a lot of posts about it to look through, but I was wondering: how are you accessing your selfhosted stuff? I would love to have some sort of dashboard with monitoring and statuses of all my services, so should I just setup WireGuard and then access everything locally? I wanted to have it behind a domain, how would I achieve it? E.g. my public site would be at example.com and my dashboard behind dash.example.com, but only accessible locally through a VPN.

I started to learn Docker when setting up my Caddy server, so I’m still really new to this stuff. Are there any major no-no things a newbie might do with Docker/selfhosting that I should avoid?

I’m really looking forward to setting everything up once I have it planned out, that’s the most fun part for me, the troubleshooting and fixing all the small errors and stuff. So, thank you for your help and ideas, I can share my setup when it’s done.

  • cybersandwich@lemmy.world
    link
    fedilink
    English
    arrow-up
    26
    ·
    11 months ago

    The major think noobs tend to mess up with docker is not setting up volumes properly so when you get rid of the instance, you lose all of your data.

    I also highly recommend docker-compose for ease of use.

    Id recommend looking up security best practices for docker as well. Things like setting a user id & gid for the containers add an additional layer of security.

    Oh and make sure you get your containers from trustworthy sources.

    • Moonrise2473@feddit.it
      link
      fedilink
      English
      arrow-up
      13
      ·
      11 months ago

      exactly, when for example the nextcloud documentation says:

      To start the container type: docker run -d -p 8080:80 nextcloud

      is not exactly clear that all the data will be 100% lost when the docker container is closed

      And when it says more down in the docs “just use volumes to persist data” - yeah how to backup those volumes? No mention at all…

      Should tell to mount a directory rather than a volume. Backup a directory is easy and everyone can do it, backup a docker volume, good luck, your data has an invisible time bomb

      • Mike@fikaverse.club
        link
        fedilink
        arrow-up
        1
        ·
        11 months ago

        @Moonrise2473 @cybersandwich I both agree and disagree… but always use named volumes. Easier to manage/monitor your volumes then use an <backup-container>, maybe rclone, that shares the same volume and sends the data to some safe place

        or, if you still prefer, in your named volume section tell docker to use a custom path.

        volumes:
        myvolume:
        driver: local
        driver_opts:
        type: none
        o: bind
        device: /host/path/to/volume

    • SniffBark@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      11 months ago

      I immediately started with using docker-compose because I was playing with a “playground” server from my provider and I wanted to be able to move my setup to the “production” server after setting things up. It’s much easier than the long docker run commands some docs suggest.

      One question about the UID and GID, I’ve run into some trouble because the official Caddy image runs as root, so I had to set php-fpm also as root because otherwise it was causing problem. So what do you suggest to do with all my containers (I do not mean Caddy and php right now)? Should I run everything as the same UID and GID, or every container with it’s own user?

    • Szwendacz@kbin.maciej.cloud
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      11 months ago

      I would not recommend docker-compose for a begginer. As first, one should learn basics, then optionally switch to docker-compose to automate stuff he already know. Also bind mount volumes are a better solution for long term storage than default volumes, since docker will never delete those, and their path in host system is configurable.