tencent cloud

TencentOS Server

Docker Container User Guide

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-10-19 16:46:03
Diterjemahkan oleh AI

Using Docker Container Technology on TencentOS Server

Docker is an open-source container engine that allows applications to run easily across different OSs and supports fast, efficient, and scalable deployment. In this tutorial, we will introduce how to use Docker container technology on TencentOS Server, and share how to manage tasks and deploy containers through examples and hands-on experience.

Installing Docker

By default, Docker is not installed along with the TencentOS Server OS. Therefore, you need to install it via the command line before using Docker.

Installing Docker via YUM

1. Install Docker.
To install Docker on TencentOS Server, run the following command:
sudo yum install -y docker-ce
Note:
TencentOS Server 4 integrates the Moby component by default. The recommended installation command is: dnf install moby.
2. Start Docker.
Run Docker with the following command:
sudo systemctl start docker
3. Check the Docker status.
Check whether Docker is running with the following command:
sudo systemctl status docker

Using Docker Containers

Exercise 1: Running a Hello World Container

1. Run a Hello World container with the following command:
sudo docker run hello-world
2. Check the running status of Docker containers.
Use the following command to check the running status of Docker containers:
sudo docker ps

Exercise 2: Running an Nginx Container

1. Download the Nginx image with the following command:
sudo docker pull nginx
2. After downloading the Nginx image, run the Nginx container with the following command:
sudo docker run -d -p 8080:80 nginx
The above command starts an Nginx container in the Docker environment and maps port 80 of the container to port 8080 on the host.
3. Check the running status of Docker containers.
Use the following command to check the running status of Docker containers:
sudo docker ps
4. Access the Nginx service.
Use the following command to access the Nginx service in a local web browser:
http://localhost:8080/
The Nginx welcome page should be displayed in your local web browser.

Common Commands

Docker provides many commands that allow you to easily create, manage, and deploy containers. The following are some commonly used Docker commands:
sudo docker run: Run a new container.
sudo docker ps: List currently running containers.
sudo docker images: List current images in the local repository.
sudo docker stop: Stop a specified container.
sudo docker rm: Remove stopped containers.


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan