Chapter 14: Installing Docker & Deploying Ghost (The Blogging Platform) AMD - DEBIAN
Now that your server is live, secured, and fully armed with an SSL certificate!
We’ll deploy Ghost, a sleek, fast, and open-source blogging platform. Perfect for personal sites, portfolios, or content projects.
Step 1: Install Docker & Docker Compose
Update your system and install Docker:
sudo apt update && sudo apt upgrade -y
Optional: Create a Dedicated Docker User
If you don’t want to run everything as root or your main user, you can create a dedicated user for Docker tasks. This improves security and organization, especially in team or production environments
# Create a new user
sudo adduser dockeruser
# (Optional, usually already exists)
sudo groupadd docker
# Add user to Docker and sudo groups
sudo usermod -aG docker dockeruser
sudo usermod -aG sudo dockeruser
# Confirm group membership
groups dockeruser
1.5 – Grant Passwordless Sudo Access
To make Docker and sudo commands smoother (especially in scripts), we can give the user passwordless sudo access:
sudo visudo
Add the following line at the end of the file:
dockeruser ALL=(ALL) NOPASSWD:ALL
Then save and exit:
- Press
Ctrl + O
to save - Press
Enter
to confirm - Press
Ctrl + X
to exit
1.6 – Create Volume Directory for Docker (as root)
Let’s now prepare the directory where Docker containers (like Ghost) will store their persistent data.
These commands must be run as root (or with
sudo
)
Create the volume directory:
mkdir /vw-data
chown dockeruser:docker /vw-data
This gives the dockeruser
permission to use the volume in your container setup.
1.7 – Switch to the dockeruser
and Install Docker
Now that the user and permissions are set up, let’s log in as the Docker user and install the required packages from there — keeping things clean and secure
Switch to the user:
su - dockeruser
Install Docker & Docker Compose:
sudo apt update && sudo apt upgrade -y
sudo apt install docker.io -y
sudo apt install docker-compose -y
Check the installation:
docker --version
docker-compose --version
You should see output confirming Docker and Compose versions — meaning it’s ready to go!
Extra: Understanding docker.sock
The file /var/run/docker.sock
is a Unix socket that allows communication between the Docker client and the Docker daemon.
If permissions aren’t correct, you might run into permission denied errors when running Docker as a non-root user.
Check and fix permissions (run as root):
ls -l /var/run/docker.sock
sudo chown root:docker /var/run/docker.sock
Then make sure Docker is running and enabled:
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl restart docker
No Comments