Cloud Native 6 min read

Deploy Docker on Cloud Linux 3 and Build a Custom Nginx Image

This step‑by‑step guide shows how to install Docker CE on a Cloud Linux 3 server, create a Dockerfile that customizes an Nginx image, build the new image, and run it with port mapping so it can be accessed via a public IP address.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
Deploy Docker on Cloud Linux 3 and Build a Custom Nginx Image

Deploy Docker CE on Cloud Linux 3

Download the official Docker‑CE yum repository file (the example uses the Aliyun mirror). The file is saved as /etc/yum.repos.d/docker-ce.repo so that yum can locate the packages.

sudo wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

Install Docker CE and its dependencies. sudo yum -y install docker-ce Verify the installation by printing the client version. A typical output is Docker version 20.xx.xx, build xxxxxxx . docker -v Start the Docker daemon. sudo systemctl start docker Enable automatic start on boot so Docker survives a reboot. sudo systemctl enable docker Check the service status; the line Active: active (running) confirms a healthy daemon.

systemctl status docker
Docker service status
Docker service status

Build a Custom Nginx Image

Pull the desired base image from Docker Hub. The example uses version 1.23.4 of the official Nginx image. sudo docker pull nginx:1.23.4 Create a Dockerfile in an empty directory. The file defines the build instructions. vim Dockerfile Insert the following content:

# Use the pulled Nginx image as the base
FROM nginx:1.23.4
# Replace the default homepage with a custom message
RUN echo '<h1>Welcome, Docker! 开源技术小栈 </h1>' > /usr/share/nginx/html/index.html

Build a new image from the Dockerfile . The tag tinywan-image001:v1 consists of a repository name ( tinywan-image001 ) and a version tag ( v1 ). sudo docker build -t tinywan-image001:v1 . List local images to confirm that the new image appears. sudo docker images Run a container from the custom image, mapping host port 8888 to the container’s port 80 . The container runs in detached mode ( -d ) and is named tinywan-nginx-test .

sudo docker run --name tinywan-nginx-test -p 8888:80 -d tinywan-image001:v1

Verification

After the container starts, open a web browser and navigate to http://<public‑IP>:8888. If the page displays the custom heading Welcome, Docker! 开源技术小栈, the Docker installation, image build, and container deployment are successful.

Browser view of running container
Browser view of running container
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerDockerfileImage BuildingCloud Linux
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.