Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

Abstract

This article focuses on practical operations with Docker, introducing the usage of the docker ps container command, covering the acquisition, operation, and homepage modification of the Nginx image, explaining the features, installation, uninstallation, and operation of the BusyBox tool, and also involving the pulling and pushing of images to Hub and the creation and operation of Tencent Cloud repositories, including rich practical cases.

1. Container Command of Docker Image Repository<span>Docker</span> Command: <span>Docker ps</span>

==Usage:==

  1. Function: Lists containers (both running and previously run).
  2. Syntax:<span>docker ps [OPTIONS]</span>
  3. Alias:
  • <span>docker container ls</span>
  • <span>docker container list</span>
  • <span>docker container ps</span>
  1. Key Parameters:
  • <span>-a</span>: Show all containers, including those not running.
  • <span>-f</span>: Filter output based on conditions.
Filter Field Description Example
<span>name</span> Filter by container name <span>-f name=mycentos</span>
<span>id</span> Filter by container ID <span>-f id=abc123...</span>
<span>status</span> Filter by status (e.g., <span>running</span>, <span>exited</span>) <span>-f status=running</span>
<span>ancestor</span> Filter by image name/ID <span>-f ancestor=mycentos:latest</span>
<span>label</span> Filter by label <span>-f label=env=prod</span>
  • <span>--format</span>: Specify the template file for the return value (e.g., json or table).
  • <span>-l</span>: Show the latest container.
  • <span>-n</span>: List the last n created containers.
  • <span>--no-trunc</span>: Do not truncate output.
  • <span>-q</span>: Silent mode, only show container IDs.
  • <span>-s</span>: Show total file size.

Operation Demonstration

<span>-a:</span>

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment<span>-f:</span>

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

<span>-format (default is table format):</span>

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

<span>-l -n</span>

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment<span>--no-trunc -q -s:</span>

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • Only show shortened ID or display file size.

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • ID has become longer.

2. Acquiring Nginx Image and Modifying Homepage

First, pull the image and run it in the background:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository DeploymentMastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • Successfully pulled, check the details of the corresponding image, and you can see that the default container runs on port 80.

Run in the foreground:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository DeploymentMastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • Successfully accessed, but the foreground is occupied.

Next, use ctrl+c to terminate the foreground program:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • Found that the corresponding nginx container also stopped, making it inaccessible.

Run in the background

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository DeploymentMastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • No matter what, ctrl+c can still access.

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • Port has also been successfully mapped.

Run bash terminal

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • The bash inside the container can also use some functions, but nginx needs to be manually run.

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository DeploymentMastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • It is found that no matter what, the webpage can still be accessed.

Next, modify the homepage (find the corresponding HTML and complete the modification):

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository DeploymentMastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • Meets expectations.

==In summary:==

The Docker image opened here is equivalent to a main function, and nginx can be understood as a website when it runs. It can be chosen to run in the foreground or background. If it runs in bash, it enters the container and opens a terminal for basic command interaction, but nginx needs to be manually input to run. If started, it also runs in the background by default, meaning commands can still be input from this terminal.

3. Installing BusyBox and Completing Image Pulling and Pushing in Hub

Basic Knowledge of BusyBox

  1. Definition and Function:
  • BusyBox is a software that integrates over 300 of the most commonly used Linux commands and tools.
  • It includes simple tools (like ls, cat, echo, etc.) and complex tools (like grep, find, mount, telnet, etc.), and also integrates the Linux system’s built-in shell, HTTP server, and telnet server.
  • Due to its rich functionality and small size (about 1MB), it is known as the Swiss Army knife of Linux tools.
  1. Overseas Bandwidth: Overseas bandwidth is limited, making it suitable for pulling this image and pushing it to one’s own repository.

<span>In summary: it is a toolkit that integrates many Linux commands.</span>

Uninstalling BusyBox

  1. Uninstalling on Ubuntu: Use the command <span>apt --purge autoremove busybox</span>.
  2. Uninstalling on CentOS: Clean the corresponding directory (the document does not provide specific commands, manual cleaning of related directories is required).

Installing BusyBox

  1. Installing on Ubuntu: Use the command <span>apt install -y busybox</span>.
  2. Installing on CentOS:
  • Step 1: Download via <span>wget https://busybox.net/downloads/binaries/1.28.1-defconfig-multiarch/busybox-x86_64 --no-check-certificate</span>.
  • Step 2: Execute <span>mv busybox-x86_64 busybox</span> to rename.
  • Step 3: Execute <span>chmod +x busybox</span> to grant permissions.
  • Step 4: Execute <span>./busybox</span> to run.

Demonstration of Running (CentOS + Ubuntu)

CentOSMastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

Since it will crawl to the current directory, first create a directory and then crawl:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

Grant it the corresponding execution permissions: Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment Next, let’s look at the supported commands:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

Run a test effect:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

UbuntuMastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

First delete and then install:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment Perform the corresponding test: Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • It is found that there are still differences compared to CentOS.

Image Testing

First perform a pull:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository DeploymentMastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • It was mentioned that it has been pulled before.

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment Next, create a repository, give it an alias, and complete the push:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository DeploymentMastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • Finally, after pushing, you can see the content (you can also push multiple with different tags directly using <span>docker push repository_location -a</span>).

4. Creating an Image Repository on Tencent Cloud and Completing Repository Operations

First, log in to the official website: Tencent Cloud Official Website

Search for image services to enter: Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository DeploymentMastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

First, create a namespace:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

Set it to private for easier testing later:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

You can see that corresponding shortcut commands are provided, and then proceed with the operation:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

First, log in with the corresponding Linux account:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment Find the corresponding image to complete the push:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

Proceed to tag:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository DeploymentMastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • Tagging here is to facilitate identification of the location when pushing in Linux.

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • Successfully completed the push.

Check the corresponding repository:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

Next, pull it down:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • Normal pull.

Next, log out and test the pull:

Mastering Docker End-to-End: Container Management, Nginx Homepage Customization, BusyBox Tool Practice, and Tencent Cloud Repository Deployment

  • It is found that re-login is required because it is set as a private repository.

5. Practical Application Summary Based on Images

  1. Generally, large companies have dedicated image production organizations that select corresponding system versions as base images, such as Huawei selecting Euler and Tencent selecting TLinux.
  2. Images produced by large companies undergo strict security scanning and serve as basic components for various departments, avoiding issues of unusable original systems due to lack of maintenance.
  3. Generally, companies also recognize the base version of images, and individuals do not need to be too entangled when choosing base images.

6. Conclusion

This article covers practical operations with Docker container commands, Nginx applications, BusyBox tools, and cloud repository operations, mastering Docker image management, container operation, and private repository usage, familiarizing with the entire process from basic operations to cloud deployment.

Leave a Comment