How to Install and Use Docker on Linux Servers
Docker packages an application and everything it needs into a container, so it runs the same way on any server. It is a common way to run self-hosted apps on a VPS.
Install Docker
On Debian and Ubuntu, the simplest route is the distribution's package:
sudo apt update
sudo apt install docker.io
On CentOS, AlmaLinux and Fedora, add Docker's own repository (see Docker's install guide for your system), then:
sudo yum install docker-ce
Start it, make it start on boot and check that it is running:
sudo systemctl enable --now docker
sudo systemctl status docker
Run your first container
sudo docker run hello-world
sudo docker run -d --name web -p 8080:80 nginx
sudo docker ps
The second command starts an nginx web server in the background and makes it available on port 8080. Stop and remove it with sudo docker rm -f web.
Everyday commands
docker ps -alists containers;docker imageslists downloaded images.docker logs <name>shows a container's output.- Build your own image from a
Dockerfilewithdocker build -t myapp ..
Containers use memory, so give a Docker host at least 2 GB of RAM if you plan to run several.
Need a server for this? Cheapest VPS plans with 2 GB RAM or more
- 2 GB KVM VPS Special2 CPU · 2 GB RAM · 35 GB disk · 5 TB bandwidth · New York, Los Angeles, Chicago$35.99/yrabout $3.00/moView at RackNerd
- 4 GB KVM VPS Special3 CPU · 4 GB RAM · 60 GB disk · 7 TB bandwidth · New York, Los Angeles, Chicago$59.99/yrabout $5.00/moView at RackNerd
- 6 GB KVM VPS Special6 CPU · 6 GB RAM · 100 GB disk · 12 TB bandwidth · New York, Los Angeles, Chicago$89.99/yrabout $7.50/moView at RackNerd
In stock when this page loaded. See all 14 matching plans