This artcile is written almost entirely because I want to send this to new members of my team(s) and have (hopefully) very similar environments on all our dev machines.
Should You Follow This?
You should only follow this guide if …
- You are using Ubuntu (or derivative distros)
- You want to reduce pain and maximize joy when working in a team.
- (optional) You are an engineer at FringeCore_ (this is an opinion piece)
1. Install Docker
I would highly highly encourage the use of the convenience script to install Docker. I’m actually rather surprised more people aren’t using this method of installation (maybe it’s because it’s not on top of the list).
# we don't want the installer to stick around.cd /tmp
# ensure you have the right packagessudo apt install curl
# this one get's the actual installercurl -fsSL https://get.docker.com -o get-docker.sh
# this one installs it.sudo sh get-docker.sh
2. Setup Docker Rootless
Using sudo
every time you run a docker command is a pain, and often it makes it impossible
to automate.
2.1. Setup
# Ensure the dependencies are present.sudo apt-get install uidmap docker-ce-rootless-extras -y
# Disable the system-wide daemon. (do you really need it on a dev machine?)sudo systemctl disable --now docker.service docker.socket
# dockerd-rootless-setuptool.sh installdockerd-rootless-setuptool.sh install
Hopefully the above commands should just run as-is.
2.2. Ask Docker CLI to Use It
Open ~/.bashrc
in an editor. (Yes, I use nano. Fight me.)
nano ~/.bashrc
Paste this at the very end.
export PATH=/usr/bin:$PATHexport DOCKER_HOST=unix:///run/user/1000/docker.sock
Save and exit out of the eidtor with Ctrl
+O
, Enter
, Ctrl
+X
.
2.3. Reload Your Terminal environments
source ~/.bashrc
3. Allow Privileged Ports
Who install nginx on the host machine anymore anyway.
# this one tells your system to allow it.sudo setcap cap_net_bind_service=ep $(which rootlesskit)
# notice the lack of `sudo`systemctl --user restart docker
4. Start + Start-up
# start it right nowsystemctl --user start docker
# at bootsystemctl --user enable docker
5. Enable Long Running Processes
That don’t exit as soon as you close your terminal.
This section is copied directly from my 🐋 Stop Rootless Docker From Exiting post.
5.1. Enable Linger
sudo loginctl enable-linger $USER
5.2. Edit systemd’s Login Session Config
Open /etc/systemd/logind.conf
in a privileged editor.
sudo nano /etc/systemd/logind.conf
Add this to the end.
UserStopDelaySec=infinityKillUserProcesses=no
Then restart the docker service.
systemctl --user restart docker.service
6. (Optional) Allow Rootless Docker to pass NVIDIA GPU
Open up this file in your text editor. /etc/nvidia-container-runtime/config.toml
sudo nano /etc/nvidia-container-runtime/config.toml
Steps:
- Find the line
#no-cgroups = false
under[nvidia-container-cli]
- Uncomment the line.
- Change it to
true
This will allow rootless docker and docker compose to forward GPU with all its various capabilities to containers.
Done
Enough opinions on how to setup your environment for the day. Welcome to our team.