Docker

From Nest Guides

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 super easy to set up with the Nest CLI! Just run:

nest setup docker

It will run all of the necessary commands to get rootless Docker working for you on Nest!

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!