Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Docker

From Nest Guides
Revision as of 00:13, 28 March 2024 by Samuel (talk | contribs) (Fix daemon-reload and add reference to Nest Postgres)

Docker is a powerful platform and tool for developing, shipping, and running applications. It utilizes a technology called containerization, which basically packages whatever program you'd like into a lightweight container, isolated from the system. Containers are great to use since they allow you to run whatever you'd like with a single command, without having to install dependencies. For example, you can run MySQL in a container with a single command!

Need a database? Nest runs an instance of PostgreSQL that should work for most use cases!

Usually, Docker runs as a system-wide service only accessible by the root user. However, since users on Nest don't have access to the root user, users can't utilize the system-wide service. Instead, you should use rootless Docker.

Rootless Docker

Rootless Docker is relatively simple to set up - just run the following commands in the terminal:

dockerd-rootless-setuptool.sh install
sed -i '/^ExecStart/ s/$/ --exec-opt native.cgroupdriver=cgroupfs /' ~/.config/systemd/user/docker.service
systemctl --user daemon-reload
systemctl --user enable docker
systemctl --user start docker
docker context use rootless

These commands will setup rootless Docker, fix a bug, start the Docker service, and configure the docker command to use rootless Docker. Once you run these commands, you'll be able to use Docker!

Using Docker

There's two core Docker concepts to understand before using Docker: images and containers. Containers are like what was said at the start of this guide - just an isolated box where a program can run, with all of its dependencies already there. But what's an image? An image is a read-only template with instructions for creating a Docker container. There's lots of different images that you can use; for example, there's one for PostgreSQL, another for a Minecraft server, and so on. You'll find most Docker images on Docker Hub.

To create a container, you can use the docker run command. Try running docker run hello-world. You should see a message from Docker after the image is downloaded!

There's a lot more that you can do with Docker. Most images on Docker Hub will give you some instructions on how to use it (such as required environment variables). Check out the Docker docs for more information!