Guide  When you purchase through links on our site, we may earn an affiliate commission. Here’s how it works.

Self-hosting: Installing Docker and an Excalidraw container on Linux

Welcome to the fourth article in the series. In case you've missed it, here's what has been covered so far, and you can always see all of the articles by looking for the the selfhosting-guide tag on Neowin.

These guides build upon each other, so if you're following along at home, I highly recommend walking through the previous articles before trying this one.

What is Docker?

So what is Docker, and why am I writing a guide to assist you installing it? In a nutshell, Docker is a way to run virtualized containers on an operating system. Developers love it because they can write code on their machine and because of the portable nature of Docker, they can move the container and run it pretty much anywhere they want, without having to worry about library dependencies or other things that could slow down the development process. The idea is someone can package up their code into a container and then you simply download and run that container on your system without having to compile code, hope you have the same libraries in the same file paths, and things like that. If you want to see the different projects that already have containers that are ready for you to download, you can check out Docker Hub.

While I'm covering the steps to install and run Docker on Linux, you can also run it on Windows if you want. However it's not really recommended. If you have no other choice for whatever reason, then install Windows Subsystem for Linux (WSL) and then install Docker on top of that, but that's outside the scope of this guide.

Installing Docker on Rocky Linux

Prerequisites

Before doing any work on a Linux system, it's important that you have an SSH client so that you can actually connect to the server. While I won't go into specific steps here, if you've never used SSH before, I can highly recommend puTTY. It's free, easy to use, and is an industry standard. It's also what I use on a daily basis at my full-time job.

A screenshot showing the use of ssh from Powershell

If you're running Windows 10 or later, then you can use SSH that is built into Powershell. Simply open up Powershell from the command prompt and then type: ssh [USERNAME]@[IP ADDRESS]

If your username on Windows is the same as the username on Linux, then you can omit it and just type: ssh [IP ADDRESS]

Some other popular SSH solutions are SecureCRT, Royal TS (or Royal TSX if your on Mac OS), or MobaXterm.

Server Setup

First, make sure your server is running. If you're following our guides and have Rocky Linux installed on Proxmox, you simply do the following:

Screenshot of Proxmox showing the steps to start a Rocky Linux server

  1. Select Datacenter->proxmox1->103(RockyLinux2); replace this with your VM name if you used a different one from what was described above
  2. Click Console
  3. Click on Start Now; this will boot the VM with the ISO you selected during setup

Next, I'll cover updating the Linux VM. This is optional, but it's recommended to keep your Linux system up to date and it doesn't take long to do.

  1. SSH to the server
  2. Run dnf check-update to look for any packages that need to be updated
  3. Run dnf update to actually update all of the packages identified in the previous step
  4. Run shutdown -r now. The -r flag means to "reboot" the server, and "now" is when it should happen. You can replace -r with --reboot, as they mean the same thing. You can also use, -P or --poweroff to shut the virtual machine off.

Installing Docker

Now that the setup work is complete, here's how to actually install Docker on the Linux VM in nine simple steps!

  1. Run dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo. This adds the repo where Docker lives so that you can install and update it automatically.
  2. Run dnf install docker-ce docker-ce-cli containerd.io. This begins installation of the three main components of Docker.
  3. Type y to install the components and required dependencies
  4. Type y a second time to continue the installation
  5. Run systemctl start docker to start running Docker
  6. Run systemctl status docker to check the status and confirm it's running properly
    1. Confirm that you see "Active: active (running)
  7. Run systemctl enable docker to ensure Docker will run upon reboot
  8. Test the persistence by rebooting the server (shutdown -r now), then login and check the status (systemctl status docker)

Installing Your First Container: Excalidraw

To test that Docker is running and to show how easy it is to start new containers, I'll provide the steps to install Excalidraw. This is a self-hosted drawing tool that stores everything in the browser, meaning you don't have to worry about Docker persistent storage yet or having databases setup to store data. You simply install and run the container, point your web browser to the port you selected, and you can start drawing cool things on the screen.

Commands on how to install the Excalidraw Docker container

  1. Run docker pull excalidraw/excalidraw to download the image
  2. Run docker run --rm -dit --name excalidraw -p 5000:80 excalidraw/excalidraw:latest to run the container from the image. 5000:80 maps internal Docker network port 80 to port 5000 on the server. If this is your first container, you could do 80:80 and then just point the browser to the server. You can also use a reverse proxy, something I'll cover in a future article.
  3. Run docker ps to confirm the container is running; in our case, it has container ID of 439eccfd2b04

An example of a Mermaid flowchart and a box chart drawn in Excalidraw running on Docker on Proxmox

You now have Excalidraw up and running on your Rocky Linux 9 server, sitting on top of Proxmox, and it was pretty easy to do! Open up a web browser, point it to port 5000, and you can start making cool drawings that can be saved to your local computer. The best part is that it only took three commands to do it, once Docker was installed on your VM!

Useful Docker Commands

Now that you have Docker working and a container running on your server, you'll want to understand some of the basic commands you'll be using to manage Docker, so I'll cover a few of the most important ones here.

  • docker ps: This shows the list of all running Docker containers/processes. It shows the container ID, the name of the container, when it was created, and what the current status is.
  • docker ps -a: Similar to above, but this shows all Docker containers/processes that were running in the past as well.
  • docker ps -s: Similar to above, but this also shows how much memory the container is using
  • docker images: This shows the list of all Docker images you've downloaded and that are sitting on disk. It shows the name of the repository, the tag (version), the image ID, when it was created, and how much disk space it's using.
  • docker exec: This is used to run a command in a running container. It t takes the Container ID and the command you want to run as input. e.g.: docker exec 439eccfd2b04 ps -ef
  • docker logs: This is used to show logs from a running container. It takes the Container ID as input. e.g.: docker logs 439eccfd2b04
  • docker pull: As shown in the Excalidraw example, this is used to download a container image from Dockerhub or elsewhere. It takes the name of the container image as input.
  • docker stop: This stops a running container. It takes the Container ID as input. e.g.: docker stop 439eccfd2b04
  • docker rm: This is used to delete a container and takes the Container ID as input. e.g.: docker rm 439eccfd2b04 to delete the Excalidraw container from our example
  • docker rmi: This is used to delete an image from disk and takes the Image ID as input. e.g.: docker rmi a798336f05e7 to delete the Excalidraw image from disk from our example above.

Another interesting thing to keep in mind about Docker containers is that you don't have to use the entire Image or Container ID. You only need to use enough to make the hash value unique. For example, to stop the running container in our example, you could use the command docker stop 439 and it would stop because there were no other containers that started with those three characters.

Conclusion

This is just scratching the surface of what you can do with Docker. You can setup different networks (docker network), have different volumes (docker volume), or even make a new container if you change yours (docker commit).

If you're new to Linux, rememebr that the man command is your friend: Use man [command] to get specific usage details on any command on the system, not just Docker.

Did you know that Neowin has a forum section? If you're playing with Docker and have some questions, feel free to post in this thread or on one of the forums to get answers from other like-minded individuals!

Report a problem with article
doogee dk10
Next Article

Doogee DK10 review: thin and light AMOLED 5G phone in a rugged package

Kingston FURY Beast DDR5 RGB Memory
Previous Article

64GB Kingston FURY Beast DDR5 RGB CL40 DIMM Memory drops to its lowest price ever

Join the conversation!

Login or Sign Up to read and post a comment.

2 Comments - Add comment