Ever since I started exploring the self-hosted landscape, I’ve deployed hundreds of containers on Docker. After all, it’s one of the simplest ways to host apps on your local server. It’s also helpful that several apps now have Docker images that can be containerized on your computer. Since Docker is a cross-platform app, you can use these Docker images to host apps on your PC, an old laptop, an SBC like a Raspberry Pi, or even your NAS. While hosting apps using Docker is fairly straightforward, it may be slightly intimidating for beginners — especially if you don’t have prior experience using a terminal.
That’s one aspect that kept deterring me from trying Docker for the longest time. As a result, I couldn’t explore the world of self-hosted apps — which I’m now addicted to. A couple of months back, I decided to let go of my inhibitions and try Docker for the first time. I spent some time with it, went through the community notes to figure out solutions whenever I was stuck, and realized that some key commands can help you navigate through Docker. So, I decided to compile some of these commands, along with how they’re helpful. Think of it as a beginner’s cheatsheet to get started with Docker.
Related
I use Docker Desktop with no coding experience and here’s what I’ve learned
It’s possible, but there are some hurdles
5
Downloading images from a registry
It automatically does it for you
docker pull [image]
Whenever you want to run a Docker container on your machine, you first have to download the image onto your computer. While you can do that via the Docker hub, it’s much simpler and quicker to do it directly via a command inside the terminal. Enter the name of the image at the end of the command and hit Enter. Docker will first look for the image on your computer’s local storage. If it’s not available, it will directly download it from the relevant registry.
You can also append the command with a certain version of the image, if you wish to download that specific one. This is helpful when you know that a certain version is stable or has bugs, so you can pick the most relevant one.
4
Creating and running a container
Deploy your favorite apps
docker run [image]
Once you download an image, it’s time to containerize and run it. The above command creates a container from the downloaded image and launches it. There are several variants of the command that include -d or -p to run containers in detached mode, or map them to a certain host.
Once you run a container, you can access the app or service by heading to your web browser and navigating to the host. You can read more about the variations in Docker’s official documentation.
3
Troubleshooting with logs
Figure out what went wrong
docker logs [container]
There may be instances when you’re unable to run or start a container. Several reasons could lead to this issue, but it’s not possible to identify the issue without delving deeper. In such cases, obtaining the logs can turn out to be rather helpful.
Logs contain a detailed description of what went wrong when trying to run a container. You can use this information to troubleshoot the problem. For instance, some self-hosted apps need a companion data folder to store config files. If that folder hasn’t been created, the container may not run. Viewing the log will tell you the issue.
2
Verify if a container is running
Double-check for surety
docker ps
If you’re like me, you may want to run multiple apps and services at once. In such situations, it’s important to know the list of containers that are running simultaneously. This is also helpful if you want to perform a certain operation on a container, and want to know whether it’s active.
The original command shows up containers that are currently active. Append it with -a to get a list of containers that have been stopped as well. If you’re facing issues with a service, you can run this command to see if it’s still running. That can narrow down the troubleshooting process.
1
Rename your containers
For better organization
docker run --name [custom name]
Whenever you install a container, Docker assigns it a name by default. Granted, these names are quite cool and catchy, but you may not remember every single one of them, especially if you have a bucketload of containers.
Use the above command when running a container for the first time to give it a custom name. If you host a lot of apps like I do, this can be a lifesaver.
Master your self-hosting ecosystem
Since Docker is one of the simplest ways to self-host apps, getting the hang of the app and its basic commands helps with trying out multiple apps and services for different requirements. If things go wrong, knowing a few commands to identify issues and troubleshoot them can come in handy, since not all containers may work seamlessly. Understanding the way these commands work can also help you learn more about Docker, how apps are hosted on servers, creating different volumes, interacting with the terminal, etc.

Related
I use these 4 tools to enhance my Docker experience
A basic Docker installation is fine and all, but these four tools can elevate its functionality to the next level