This guide assumes you’re running Ubuntu 18.04 or newer. To run Ghost in Docker, a minimum of 1 GB of RAM and a decent CPU are recommended.

Prerequisites
- You should have a VPS running Ubuntu 18.04 or newer.
- You should have root or sudo access to the server.
Step 1: Update System Packages
First, SSH into your VPS and update the package lists to ensure everything is up to date.
sudo apt update && sudo apt upgrade -y
Step 2: Install Docker
If Docker is not installed yet, run the following commands to install it.
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL <https://download.docker.com/linux/ubuntu/gpg> | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] <https://download.docker.com/linux/ubuntu> $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce
Verify that Docker is installed correctly:
sudo docker --version
Use apt to install all packages required by Docker:
sudo apt-get update
sudo apt-get install \\
ca-certificates \\
curl \\
gnupg \\
lsb-release
Step 3: Run Jenkins Using Docker
Now that Docker is installed, you can run Jenkins using the command you provided. This command maps the necessary ports, sets up a restart policy, and mounts a volume for Jenkins' data:
docker run -p 8080:8080 -p 50000:50000 --restart=on-failure -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts-jdk17
Explanation of the Command:
p 8080:8080
: Exposes Jenkins on port 8080 for the web interface.p 50000:50000
: Exposes Jenkins on port 50000 for the agent-to-master communication.-restart=on-failure
: Automatically restarts the container if it crashes.v jenkins_home:/var/jenkins_home
: Mounts a volume namedjenkins_home
to persist Jenkins data.jenkins/jenkins:lts-jdk17
: Uses the Jenkins LTS version with Java 17.
Step 4: Access Jenkins
Once the container is running, you can access Jenkins via the web browser using the server's IP address on port 8080:
http://<your_vps_ip>:8080
- Check Docker Container Status
- Verify OCI Security List / Firewall Rules
- Go to the Oracle Cloud Infrastructure console.
- Navigate to your compute instance.
- Under "Networking", check the Security Lists or Network Security Groups associated with the instance's VCN (Virtual Cloud Network) subnet.
- Ensure that the following ingress rule exists:
- Source CIDR:
0.0.0.0/0
(or restrict to your IP) - IP Protocol:
TCP
- Destination Port Range:
8080
- Source CIDR:
- Check Ubuntu Firewall (UFW)
- Verify the Public IP Address
- Check for Port Conflicts
- Test Locally
If Jenkins is not accessible on http://<your_vps_ip>:8080
Here's a checklist to troubleshoot and resolve the issue:Ensure that the Jenkins container is running properly:
docker ps
If Jenkins is not running, look at the container logs to find out why it failed:
docker logs <container_id_or_name>
OCI uses security lists or network security groups (NSGs) to control inbound and outbound traffic. Ensure that the appropriate port (8080) is allowed for inbound traffic on your VPS.If the rule does not exist, add it.If UFW (Uncomplicated Firewall) is enabled on your Ubuntu VPS, you may need to allow traffic on port 8080:
sudo ufw allow 8080/tcp
sudo ufw reload
Check the firewall status:
sudo ufw status
Ensure that you're using the correct public IP address for your VPS. You can check the public IP by running:
curl ifconfig.me
Make sure you're accessing http://<your_public_ip>:8080
and not the private or incorrect IP.Make sure no other service is already using port 8080. You can check this by running:
sudo lsof -i :8080
If there’s a conflict, you can stop the conflicting service or run Jenkins on another port.To check if the Jenkins container is accessible locally on the server, SSH into your VPS and run:
curl <http://localhost:8080>
If you receive the Jenkins login page HTML, it means the service is working but there may be a network issue preventing external access.
Step 5: Retrieve the Initial Admin Password
When you first start Jenkins, you'll need to unlock it using an initial admin password. You can retrieve it by running the following command:
cat /var/jenkins_home/secrets/initialAdminPassword
Replace <container_id_or_name>
with the actual container ID or name of your Jenkins container. You can find the container ID by running docker ps
.
Step 6: Complete Jenkins Setup
Follow the on-screen instructions to complete the Jenkins setup and install recommended plugins.
After this, Jenkins should be up and running on your OCI Ubuntu VPS!
Step 6: Install Nginx
To set up Jenkins with Nginx as a reverse proxy, follow these steps
Start and enable Nginx:
sudo systemctl start nginx
sudo systemctl enable nginx
Install Nginx:
sudo apt install nginx
Update package list:
sudo apt update
2. Configure Nginx for Jenkins
- Replace
jenkins.apoorvaverma.in
with your actual domain name.
Reload Nginx to apply changes:
sudo systemctl reload nginx
Test the Nginx configuration:
sudo nginx -t
Create a symbolic link to enable the site:
sudo ln -s /etc/nginx/sites-available/jenkins /etc/nginx/sites-enabled/
Add the following configuration:
server {
listen 80;
server_name jenkins.apoorvaverma.in;
location / {
proxy_pass <http://localhost:8080>;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Create a new Nginx configuration file:
sudo nano /etc/nginx/sites-available/jenkins
3. Set Up SSL (Optional but Recommended)
For SSL/TLS, you can use Let's Encrypt with Certbot.
Set up automatic renewal:
sudo systemctl enable certbot.timer
sudo systemctl start certbot.timer
Obtain and install the SSL certificate:
sudo certbot --nginx -d jenkins.apoorvaverma.in
Follow the prompts to complete the process.
Install Certbot and Nginx plugin:
sudo apt install certbot python3-certbot-nginx
4. Update Jenkins Configuration
Ensure Jenkins is configured to use the correct URL. Update Jenkins settings if needed to reflect the domain:
- Open Jenkins: Go to
http://localhost:8080
and log in. - Navigate to Manage Jenkins:
- Go to
Manage Jenkins
>Configure System
.
- Go to
- Update Jenkins URL:
- Find the
Jenkins URL
field and set it tohttps://jenkins.apoorvaverma.in
.
- Find the
- Save changes.
Now, you should be able to access Jenkins via https://jenkins.apoorvaverma.in
.