this post was submitted on 07 Nov 2024
25 points (87.9% liked)

Selfhosted

40300 readers
210 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

I just start using my homelab to host some new good services, and I want to know what is the approach of a docker setup, what is the best distro for? How to deploy them correctly? Basically I'm a real noob in this subject. Thank you

top 42 comments
sorted by: hot top controversial new old
[–] [email protected] 13 points 1 week ago* (last edited 1 week ago) (4 children)

Debian with the docker convenience script. Stay away from Ubuntu server, for the love of dog.

Make a folder such as /stacks and put everything there by building docker compose stacks. I bind mount everything local to a subfolder with the docker-compose.yml for that application so when I restore it, it's all in one spot, not spread all over the hell like docker likes to do if you don't use bind mounts.

Add lazydocker for getting easy log and stats access for each stack.

Avoid bare docker run commands. It makes an unmanageable mess when you get more that a couple containers running.

Consider using the nextcloud AIO master container. It runs docker containers inside a master container compose file, and it is by far the easiest way to manage and run nextcloud.

[–] moonpiedumplings 5 points 1 week ago (1 children)

Debian with the docker convenience script.

They seem to be moving away from this, and it's not longer the first option on their install page

On their debian page

Use a convenience script. Only recommended for testing and development environments

Also, it should be noted about the first option they recommend, Docker Desktop, that Docker Desktop is proprietary.

I recommend just getting the docker.io and docker-compose from debian's repositories.

[–] [email protected] 1 points 1 week ago (1 children)

Well, that's a new development. That used to be the go-to method they pushed. Thanks for pointing that out.

As for Docker Desktop being the top option, it would only be used for a "development environment" because why would you install that on a headless docker host for production? And after the horror stories I've heard of Windows and Mac versions of Docker Desktop, there isn't a chance in hell I'd use it anyway.

So yes, going forward it looks like adding the repos and apt-get install are the way to go. Except, the convenience script was so... convenient.

[–] moonpiedumplings 1 points 1 week ago (1 children)

Debian already has docker packaged. That's more convenient.

[–] [email protected] 2 points 1 week ago

With Debian not being a rolling release id think it is relevant to stay up to date with your container daemon. IMHO.

[–] [email protected] 5 points 1 week ago

Debian + Containers is definitely the way. Literally so stable it's boring.

[–] [email protected] 2 points 1 week ago (1 children)

What is so bad about Ubuntu server?

[–] [email protected] 1 points 1 week ago (2 children)

When I tried it last (a couple years ago), the docker snap was an untroubleshootable mess. I don't like the idea of running Docker that way, in whatever version of a container that Canonical has come up with for snaps. It's just looking for problems. Run an application with Snap if you want, but a whole container system? No thanks.

[–] [email protected] 4 points 1 week ago (1 children)

I just don't use snaps and it works great for me. For docker I add their apt repository and install it like that.

[–] [email protected] 1 points 1 week ago (1 children)

Well, I wasn't using snaps and it still decided to install Docker snap on me. 2 days of troubleshooting before I figured out that the snap existed and was having a war with my apt install of docker. Never again.

[–] [email protected] 2 points 1 week ago (1 children)

I avoid apt because it does silly stuff. Always use apt-get. I suppose having to know that quirk is a con of the distro.

[–] [email protected] 1 points 1 week ago

Oh those are not the same?! TIL. Just thought they made it more convenient.

[–] [email protected] 1 points 1 week ago* (last edited 1 week ago) (2 children)

I wrote a script to remove snaps and install Docker as per the docker website. Works great mate.

Plus you get the benefit of frequent updates.

[–] [email protected] 1 points 1 week ago

I don't need what Ubuntu offers to run server applications, and Debian is rock solid and predictable. Might as well go to the source since it's Debian all the way down anyway, just with added cruft.

[–] [email protected] 1 points 1 week ago (1 children)

One of their frequent updates completely broke docker on my system. Fortunately they did push the fix by the time I realized what happened.

[–] [email protected] 1 points 1 week ago (1 children)

Is that because you installed it via snaps instead of apt?

[–] [email protected] 1 points 1 week ago (1 children)

It was from docker's apt repo, so a newer version than provided through Ubuntu's channels I assume.

[–] [email protected] 1 points 1 week ago

APT install is the same for Debian as it is for Ubuntu. Ubuntu delivers docker through APT or Snap but defaults snap.

[–] [email protected] 1 points 1 week ago (1 children)

I've become very partial to Dozzle. I roll out right into my compose scripts and it's incredibly lightweight.

[–] [email protected] 3 points 1 week ago (1 children)

I found dozzle a bit rudimentary as it only does logs, but I liked that there was an android app to interface it.

Lazydocker is more like Portainer on running stacks in that you can see logs, configs, stats and do operations on the stacks and components all from an SSH TUI.

[–] [email protected] 2 points 1 week ago

I'll have to check it out. TIL about the app.

[–] [email protected] 8 points 2 weeks ago (2 children)

Anything.

Personally I use Debian. But Docker doesn't care. I chose Debian because it is very stable and simple

[–] [email protected] 3 points 2 weeks ago (1 children)

Yep, Debian and then add Portainer - for me this is the easiest setup to manage.

[–] [email protected] 6 points 2 weeks ago (3 children)

would prefer to not use portainer

[–] [email protected] 6 points 2 weeks ago

I just said what works best for me. Use the command line and compose files if you want.

[–] [email protected] 2 points 1 week ago

I love the one click pull from git option. Don't like the corporate direction they seem to be taking.

I haven't seen aby alternative docker GUI managers that have the git pull for the compose.

[–] [email protected] 2 points 1 week ago

I can appreciate this. You might want to look at Lazydocker as a SSH TUI management tool.

[–] [email protected] 1 points 2 weeks ago (4 children)

And what is the good way of deploying it? After pulling the image, how do we autostart it etc...

[–] [email protected] 5 points 2 weeks ago (1 children)

The Docker documentation is pretty terrible, but it's a decent start. Start by looking at docker-compose.yml files for the services you want to run and the write-ups for those.

Something nobody ever told me, that I had to figure out myself, is that docker-compose.yml files can be placed anywhere you want.

[–] [email protected] 1 points 2 weeks ago (1 children)

Should I make the docker compose files or pull the image from hub.docker.com?

[–] [email protected] 4 points 2 weeks ago

Your compose file will pull the image when you run it, from the registry it's in

[–] [email protected] 3 points 2 weeks ago (1 children)

At its simplest:

docker run -d --name servicename --restart unless-stopped container

That'll get you going. Youi'll have containers running, they restart, etc. There are more sophisticated ways of doing things (create a systemd file that starts/stops the container, use kubernetes, etc.) but if you're just starting this will likely work fine.

[–] [email protected] 1 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

Are they starting automatically at boot?

EDIT : how do you run a container with a simple name instead of using his id?

[–] [email protected] 2 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

Yes - they'll start automatically. There are other options for "restart" that define the behavior.

You can give whatever you like to "servicename" and use that rather than the ID.

For example:

docker run -d --name mysite --restart unless-stopped nginx

docker stop mysite

docker start mysite
[–] [email protected] 1 points 2 weeks ago
[–] [email protected] 3 points 1 week ago

in a docker compose file you can set the option "restart: unless-stopped"

https://docs.docker.com/reference/compose-file/services/#restart

[–] [email protected] 1 points 2 weeks ago

Create a systemctl service for it, create a cron, or of there is a lot of interconnectivity between your containers look at something like K3S.

[–] [email protected] 2 points 2 weeks ago (1 children)

What do you want to do with containers? That’s sort of the driver for making architectural decisions.

[–] [email protected] 1 points 2 weeks ago

Network and services containers. Nextcloud, Homepage, filesharing, ...

[–] [email protected] 2 points 2 weeks ago (1 children)

I would start with a Debian os base, install docker and turn it into a swarm manager. Then look at stacks and how services work, if you find your running your host too hard. You can add a work host and stread out.

Once you have docker swarm running, get portainer running. I use portainer as a visual whats happening on my swarm, but I use the docker cli to start and update all my stacks. I have my stacks in a git repository so that I have a backup and history of what changes I did.

Now your a docker master, of sorts.

[–] [email protected] 1 points 2 weeks ago

thank you a lot, im gonna dive in the subject more deeply

[–] [email protected] 0 points 1 week ago

Ubuntu server is pretty user friendly and has more frequent updates op. Plenty of info out there. My preference is uninstall snaps.