Setting Up Docker on My Hosting Server (selfmade.lab)
Source: Dev.to
Step 1: Connect to the Server
ssh root@your_server_ip
After logging in, I confirmed I was inside the server.
Install Docker
apt update
apt install docker.io -y
Start and enable Docker:
systemctl start docker
systemctl enable docker
Verify the installation:
docker --version
docker run hello-world
The test container confirmed Docker is installed and running correctly.
Run PostgreSQL in a Container
docker run -d \
--name selfmade-postgres \
-e POSTGRES_PASSWORD=1234 \
-p 5432:5432 \
postgres
Allow external connections through the firewall:
ufw allow 5432
Connect from a local system (e.g., pgAdmin):
- Host:
your_server_ip - Port:
5432 - Username:
postgres - Password:
1234
The connection was successful.
Next Steps
- Use
docker‑composefor better management. - Add a FastAPI backend.
- Secure the database using an
.envfile. - Set up the domain for
selfmade.lab. - Add Nginx as a reverse proxy.
Reflections
- Initial confusion with Docker setup was resolved step by step.
- Understanding the differences between server and local environments helped.
- Port access configuration was straightforward once the firewall rule was added.
- Docker installation on a server is simple, and containers greatly simplify backend setup.
- PostgreSQL runs smoothly inside Docker, and remote connections via pgAdmin are very useful.
More updates will follow as I continue building selfmade.lab.