Docker packages an application and its dependencies into a container image. On an Ubuntu VPS, it provides a repeatable way to deploy services while keeping their environments separate.
Containers still need updates, resource planning and backups. This guide covers installing Docker Engine, checking the service and running a first container on Ubuntu 22.04 or 24.04.
Use a fresh VPS or review any existing container installation before changing packages. The commands below use a sudo-capable SSH account.
Key Takeaways
- Docker packages applications and dependencies into repeatable deployments.
- Docker Engine supports the Ubuntu 22.04 and 24.04 releases covered here.
- Containers reduce the number of dependencies and make the process much easier.
- Named volumes preserve application data independently of a container; backups are still required.
- Use images from trusted publishers and keep them updated.
- Allocate enough CPU, memory and storage for the applications you deploy.
What Is Docker? Explained as Simply as Possible
Docker runs applications in containers that share the host kernel. Each image supplies the application and its user-space dependencies; a virtual machine instead runs its own guest operating system.
When using Docker, the application together with its required dependencies is encapsulated into a package. That enables easier deployment and portability.
Benefits of Running Docker with a VPS: some of the benefits of running Docker with a VPS include:
- Facility in application deployment
- Creation of a unique environment for every application
- Reduced dependency issues
- Increased speed in updating processes
- Effective use of resources
- Good possibilities of self-hosting
- Easier portability between servers
Container images package the application environment, but you still configure networking, storage, updates and credentials for each deployment.
Prerequisites: the following are needed to set up Docker:
- Ubuntu 22.04 or Ubuntu 24.04
- A VPS server with root or sudo privileges
- SSH connectivity
- System updates and upgrades
- Stable internet connectivity
Connect with a sudo-capable account over SSH, using the username and public IP address supplied for your VPS.
Connecting to Your VPS: connect to your VPS server using SSH:
ssh username@your-server-ip
Sample command:
After signing in, prepare Ubuntu for the Docker installation.
Updating Ubuntu OS Before Installing Docker: begin by checking package lists and upgrading software packages.
sudo apt update
sudo apt upgrade -y
Install required packages:
sudo apt install -y ca-certificates curl gnupg
Install Docker on Ubuntu 22.04/24.04
The steps below use Docker’s official Ubuntu repository. Review its prerequisites and conflicting-package guidance if Docker, containerd or Podman is already installed.
Install the Docker Official GPG Key: make the keyring directory:
sudo install -m 0755 -d /etc/apt/keyrings
Download the Docker GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Set proper permissions:
sudo chmod a+r /etc/apt/keyrings/docker.gpg
Add Docker Repository
echo \
"deb [arch=$(dpkg --print-architecture) \
signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Updating Package Information
sudo apt update
Installing Docker Engine
sudo apt install -y docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-plugin
Checking Docker Installation: Let’s check whether Docker is installed properly.
Checking version number:
sudo docker --version
Expected output:
Docker version <installed-version>
Checking service status:
sudo systemctl status docker
The service status should show active (running). If it is stopped, start it with sudo systemctl start docker. Press Q to exit the status view.
You can check for start-up settings also:
sudo systemctl is-enabled docker
Expected output:
enabled
Run Your First Docker Container: Docker offers a test container named hello-world.
sudo docker run hello-world
This will:
- Download the image
- Create a container
- Run the test
- Print a message
Docker is working properly if the message prints correctly.
Docker Basics Knowledge
Let us talk about some key concepts before you deploy your application.
Images are templates for creating containers.
For example:
- Nginx
- WordPress
- Ubuntu
- PostgreSQL
- Open WebUI
Containers: Containers are live instances of images. They can be started and stopped and restarted and deleted individually.
Volumes: Data can be stored permanently using volumes on the host machine. This will help make sure that the data is preserved despite recreating the containers.
Networking: The containers can communicate with each other via Docker networking. This becomes essential while working with different services.
Always wise to start with Docker Compose right from the beginning of application development. The configuration files will enable you to deploy the application and save a lot of time too.
Docker Commands for Any VPS Administrator to Remember
Show running containers:
sudo docker ps
Show all containers:
sudo docker ps -a
Download an image:
sudo docker pull nginx
Start a container:
sudo docker run nginx
Stop a container:
sudo docker stop container-name
Restart a container:
sudo docker restart container-name
Check logs:
sudo docker logs container-name
Get a shell within a container:
sudo docker exec -it container-name bash
Delete a container:
sudo docker rm container-name
This should handle most common tasks regarding managing Docker containers.
Deployment of Useful Software
Done with Docker testing. Now time to put it to use.
How to deploy Nginx?
Deploy an Nginx-based server:
sudo docker run -d \
--name nginx-server \
-p 8080:80 \
nginx
Check that it works:
sudo docker ps
Open http://YOUR_SERVER_IP:8080 in a browser. The example publishes Nginx on port 8080; that port must be unused and reachable. Docker-published ports can bypass UFW rules, so apply the firewall guidance in Docker’s installation documentation.
“Docker simplifies application deployment, but the VPS gives you the control and resources to run those containers reliably and at scale.”
Hamza AitizadWordPress Content SpecialistUsed Applications Which Can Be Found in Docker
A lot of very helpful applications that their developers offer through Docker are:
- WordPress
- Portainer
- Open WebUI
- Ollama
- n8n
- Private AI assistants
Installing such applications is likely going to be quicker through Docker.
Docker Containers Management
Starting container:
sudo docker start container-name
Stopping container:
sudo docker stop container-name
Restarting container:
sudo docker restart container-name
Removing container:
sudo docker rm container-name
Deleting image:
sudo docker rmi image-name
Cleanliness is important for preserving the space available on your VPS.
Data Persistence and Docker Volumes
One of the most important aspects of Docker is persistence.
A container’s writable layer survives a restart, but is removed when the container is deleted. Named volumes persist separately; back them up because persistence is not a backup.
Creating a volume:
sudo docker volume create appdata
Mounting a volume:
sudo docker run -d \
--volume appdata:/data \
your-image
Some advantages of using volumes are:
- Persistent application data
- Simple backup
- Easy migrations
- Safeguarded upgrades
Make sure to use volumes to store data in production deployments.
Basics of Docker Security
There are several best practices to consider to improve Docker security.
Image Updates: Pull the updated image, then recreate the container using the same configuration and persistent storage. Pulling an image alone does not update an existing container.
sudo docker pull image-name
Use Official Images: Always prefer to use images released by trusted publishers.
Port Limitations: Publish only necessary ports for applications to be accessible.
Least Privilege Principle: Run Docker containers as a limited privilege user.
Ubuntu Updates: Make sure to keep both Docker and the host OS up to date.
Next Up for Self-Hosting: You can explore various self-hosting projects once Docker is installed.
These may include:
- Ollama for local AI
- Open WebUI for AI chat UIs
- n8n for automation
- AI agents and assistants
- WordPress websites
- Personal clouds
- Monitoring systems
This is where Docker comes in handy. Almost all modern self-hosting projects have Docker deployment guides included.
For the next deployment, use the chosen application’s own installation guide and resource requirements.
Why Docker Works Well with VPS Hosting
Docker and VPS hosting go great together.
The reasons are:
- Allocated virtual CPU, memory and storage
- Root access
- Control over OS
- Networking flexibility
- Scalability
Whereas Docker will provide:
- Portability of applications
- Consistency in deployments
- Easier updates
- Optimization of resource usage
The two technologies create an ideal platform for development and hosting.
Running Docker on an UltaHost VPS
Docker requires a platform that allows its users to have control of the operating system.
VPS accounts from UltaHost come with root access and a Linux-based operating system. Our VPS provides you with enough flexibility required for Docker containers.
Our VPS lets you customize the server as you desire. Be it setting up one website or developing new software, or even running multiple applications on your own. We give you the liberty to do all of that.
Thinking of self-hosting applications? Set up Docker or even run artificial intelligence applications. Having VPS hosting helps in such situations.
Conclusion
Docker provides a repeatable way to deploy applications on an Ubuntu VPS. Install it from the official repository, verify the service with hello-world and keep the host and container images updated.
Plan networking and persistent storage before adding production data. Back up volumes and configuration, and test recovery so that replacing a container does not put the application’s data at risk.
For each application, follow its supported deployment instructions and allocate enough CPU, memory and storage for the workload.
FAQ
How do I install Docker on Ubuntu 22.04?
You need to update the OS. Add the official repository. Install Docker Engine from APT. The official repository supplies Docker Engine packages for supported Ubuntu releases.
How do I install Docker on Ubuntu 24.04?
The process is almost the same as on Ubuntu 22.04. Add the Docker official repository. Refresh the local cache. Install Docker Engine and some additional packages.
How do I run applications with Docker on VPS?
Pull an image with the desired application from Docker Hub. Run that app using the ‘docker run’ command. You will have to map ports and mount a volume for storage.
What do I need to do after Docker installation?
Check installation by running ‘hello-world’. Learn how to use Docker basic commands. Create storage volumes. Run some applications like Nginx, WordPress, Portainer, Open WebUI, or n8n.
Is Docker suitable for self-hosting?
Yes. Docker is among the most popular options for self-hosting since Docker is easy to deploy. It allows application isolation and reduces software conflicts. Updates or migration is much easier.