Self-Hosting Series: Part 2
Docker and Portainer
Requirements
- Software
- A Linux distro (Guide is based on Debian)
- Root access (or a user with sudo privileges)
- A basic understanding of Linux commands
- Docker
- Portainer
- Hardware
- A good ol' computer (laptop or desktop)
Intro
Docker is an essential tool for self-hosting, allowing you to deploy and manage applications in isolated environments (containers).
Portainer is a powerful web-based management tool for Docker, making it easier to deploy and manage containers without complex CLI commands.
In this guide, weβll walk through installing Docker and Portainer on a Debian system step by step.
Step 1: Install Docker and Docker Compose
The easiest way to install docker is by running the following script. This will install Docker engine and its dependencies:
Note: NEVER run a script without knowing what’s inside. Always examine carefully before run.
curl -fsSL https://get.docker.com | sh
Optional: If we want to run docker as a regular user and without sudo command, we should add the user to the docker group:
sudo usermod -aG docker <yourusername>
Verify Docker is installed:
docker --version
Next, install Docker Compose:
sudo apt install docker-compose -y
Verify installation:
docker-compose --version
Run the following command to test if Docker is working:
docker run hello-world
If everything is set up correctly, you should see a message confirming that Docker is installed and working.
2: Ensure docker is running
Portainer runs as a Docker container, so let’s make sure Docker is running:
sudo systemctl status docker
3: Create a Docker Volume for Portainer
Portainer stores data in a Docker volume to persist settings and configurations. Create it with:
docker volume create portainer_data
4: Deploy Portainer Container
Run the following command to start Portainer as a containerized service:
docker run -d \
--name=portainer \
--restart=always \
-p 8000:8000 \
-p 9443:9443 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:latest
Explanation of Flags :
-d β Runs the container in detached mode (in the background).
--name=portainer β Names the container portainer.
--restart=always β Ensures Portainer starts automatically on reboot.
-p 8000:8000 β Opens port 8000 for the Portainer agent.
-p 9443:9443 β Opens port 9443 (default Portainer web UI over HTTPS).
-v /var/run/docker.sock:/var/run/docker.sock β Allows Portainer to communicate with Docker.
-v portainer_data:/data β Uses the created volume for storing Portainerβs persistent data.
5: Access the Portainer Web UI
Once the container is running, open your browser and navigate to:
https://your-server-ip:9443
You’ll see a security warning because Portainer uses a self-signed SSL certificate by default. Click “Advanced” β “Proceed” to continue.
6: Create an Admin User
On the Portainer setup page , create an admin username and password. Click “Create User”.
Done! Now that docker and Portainer are installed, you can start deploying multiple self-hosted applications with ease!
Next Steps in This Series
β Deploying services using Docker Compose and Portainer. (PART 3)
β Setting up a cloudflare tunnel.
β Connect our server to our private vpn secure access.
β Hosting your own media server (Jellyfin/Plex),password manger and many more!
Stay tuned as we turn your server into a powerful self-hosted ecosystem! π