Operations 11 min read

How to Install Docker, Docker‑Compose, Nginx and Jenkins on Alibaba Cloud

This tutorial walks through preparing an Alibaba Cloud server, installing Docker and Docker‑Compose, resolving permission issues, setting up Nginx and Jenkins containers, configuring docker‑compose.yml and nginx.conf, and finally launching the environment with Docker commands, providing a complete CI/CD deployment pipeline.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Install Docker, Docker‑Compose, Nginx and Jenkins on Alibaba Cloud

The tutorial uses an Alibaba Cloud server with 2 vCPU and 2 GiB RAM, running CentOS 8.5 64‑bit.

Step 1: Install Docker

Run the following command to install Docker from the Alibaba Cloud mirror:

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

If the command finishes without error, Docker is installed successfully.

Step 2: Install Docker‑Compose

Download Docker‑Compose using the command below (may require retry due to network issues):

curl -L https://get.daocloud.io/docker/compose/releases/download/v2.4.1/docker-compose-$(uname -s)-$(uname -m) > /usr/local/bin/docker-compose

If you encounter a Permission denied error, apply one of the following fixes:

Add your user to the Docker group: sudo usermod -aG docker $USER Make the Docker‑Compose binary executable: chmod +x /usr/local/bin/docker-compose When the download still fails with a 503 Service Temporarily Unavailable HTML response, retry the command or download directly from GitHub:

curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

After making the file executable, verify the installation with docker-compose -v.

Step 3: Install Nginx and Jenkins

Pull the required images:

docker pull nginx
docker pull jenkins/jenkins

Create the directory structure for Docker, Nginx and Jenkins:

mkdir /docker
mkdir /docker/compose
mkdir /docker/jenkins_home
mkdir /docker/nginx
mkdir /docker/nginx/conf
mkdir /docker/html
mkdir /docker/html/dev
mkdir /docker/html/release
mkdir /docker/html/pro

Create placeholder configuration files:

cd /docker/compose && touch docker-compose.yml
cd /docker/nginx/conf && touch nginx.conf

nginx.conf (excerpt)

user  nginx;
worker_processes  1;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events { worker_connections 1024; }

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    keepalive_timeout  65;
    gzip  on;

    # dev environment
    server {
        listen 8001;
        server_name localhost;
        location / {
            root  /usr/share/nginx/html/dev/dist;
            index index.html;
            try_files $uri $uri/ /index.html;
        }
    }

    # sit environment
    server {
        listen 8002;
        server_name localhost;
        location / {
            root  /usr/share/nginx/html/sit/dist;
            index index.html;
            try_files $uri $uri/ /index.html;
        }
    }
}

docker-compose.yml (excerpt)

version: '3'
networks:
  frontend:
    external: true

services:
  docker_jenkins:
    user: root
    restart: always
    image: jenkins/jenkins:lts
    container_name: jenkins
    environment:
      - TZ=Asia/Shanghai
      - "JENKINS_OPTS=--prefix=/jenkins_home"
    ports:
      - 8080:8080
      - 50000:50000
    volumes:
      - /docker/jenkins_home/:/var/jenkins_home
      - /usr/local/bin/docker-compose:/usr/local/bin/docker-compose

  docker_nginx_dev:
    restart: always
    image: nginx
    container_name: nginx_dev
    ports:
      - 8001:8001
    volumes:
      - /docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
      - /docker/html:/usr/share/nginx/html
      - /docker/nginx/logs:/var/log/nginx

  docker_nginx_sit:
    restart: always
    image: nginx
    container_name: nginx_sit
    ports:
      - 8002:8002
    volumes:
      - /docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
      - /docker/html:/usr/share/nginx/html
      - /docker/nginx/logs:/var/log/nginx

Explanation of key fields: docker_jenkins – service name for Jenkins. user: root – runs the container as root. restart: always – ensures the container restarts on failure. image: jenkins/jenkins:lts – specifies the Jenkins LTS image. ports – maps host ports to container ports (8080 for Jenkins UI, 8001/8002 for Nginx dev and sit environments). volumes – mounts host directories into the containers for persistence and configuration.

Removing Jenkins Container

List containers: docker ps -a Stop the Jenkins container: docker stop <container_id> Remove the container: docker rm <container_id> Optionally remove the image: docker rmi <image_id> Use docker system prune to clean up unused resources.

Step 4: Start the Environment

Start Docker if it is not already running: systemctl start docker Enable Docker to start on boot:

sudo systemctl enable docker
sudo systemctl start docker

From the directory containing docker-compose.yml, launch all services: docker-compose up -d Check the status of the containers: docker-compose ps -a Access the services via the following URLs (replace the server IP accordingly):

Jenkins UI: http://<server_ip>:8080 Dev site: http://<server_ip>:8001 SIT site: http://<server_ip>:8002 Additional useful Docker commands mentioned: docker run – create and start a new container. docker start/stop/restart – control container lifecycle. docker exec – run a command inside a running container. docker logs – view container logs. docker rm – remove a container. docker images – list local images. docker pull – download an image. docker push – upload an image. docker build – build an image from a Dockerfile.

Version checks performed on the server:

docker -v
# Docker version 20.10.5, build 55c4c88

docker-compose -v
# docker-compose version 1.28.6, build 5db8d86f

For further details on Jenkins configuration and usage, refer to the follow‑up article.

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.

devopsNginxAlibaba CloudJenkinsDocker-Compose
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.