← Back
22 mai 2026·SharkCloud Editorial Team

Step by Step: Deploy Your First Website on a VPS with Docker

Why Docker on a VPS?

Docker lets you run your website in a clean, repeatable container, so it behaves the same on your laptop and on your server. No more dependency conflicts, no more it works on my machine. This guide takes you from a fresh VPS to a live site in a few minutes.

Before You Start

You need a VPS running Ubuntu 22.04, SSH access, and a domain name pointed to your server IP. A 1-2 core plan with 2GB RAM is plenty for a starter site.

Step 1: Install Docker

Connect over SSH and run:

curl -fsSL https://get.docker.com | sh

Then verify with docker --version. Docker Compose is included in modern installs.

Step 2: Run a Web Server Container

Launch an Nginx container that serves on port 80:

docker run -d --name web -p 80:80 nginx

Open your server IP in a browser and you should see the Nginx welcome page. That is your first container live.

Step 3: Serve Your Own Files

Mount a local folder of HTML into the container:

docker run -d --name site -p 80:80 -v /home/ubuntu/site:/usr/share/nginx/html:ro nginx

Drop your index.html into /home/ubuntu/site and refresh.

Step 4: Use Docker Compose

For anything beyond one container, write a docker-compose.yml so you can start everything with a single command: docker compose up -d. Compose makes it easy to add a database or a backend service later.

Step 5: Add HTTPS

Put a reverse proxy such as Caddy or Nginx Proxy Manager in front of your site to get free, auto-renewing Let us Encrypt certificates. Your visitors get the padlock with almost no manual work.

Keep It Running

Containers restart automatically if you add --restart unless-stopped. Schedule image updates and back up your volumes, and your site will stay healthy. Ready to try it? Spin up a VPS and you can follow these steps end to end today.

Cet article a été rédigé avec l'aide de l'IA par l'équipe éditoriale de SharkCloud et relu avant publication.