In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to install and use Docker on Linux". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to install and use Docker on Linux.
Installation
Due to the lack of a graphical interface for Ubuntu Server 16.04, I will install and use Docker entirely from the command line. Before you install, you need to update apt and then make the necessary upgrades. It is important to note that if the system kernel is upgraded, you will need to restart the system. Therefore, * pick a time when the server can be restarted.
Run the following command to update apt:
Sudo apt update
When you are finished, use the command to upgrade the system:
Sudo apt upgrade
If the kernel is upgraded, you need to restart the server with the following command:
Sudo reboot
If the kernel is not upgraded, you can install Docker (no reboot is required). The command to install Docker is:
Sudo apt install docker.io
If you are using another Linux distribution and you find that there is no docker.io package when you try to install it with the appropriate package manager, you should install the docker package. For example, to install on Fedora, you should use the command:
Sudo dnf install docker
If you are using CentOS 7, use the installation script to install docker. First update the system using the command sudo yum check-update. After the upgrade, enter the following command to download and run the required script:
Curl-fsSL https://get.docker.com/ | sh
By default, only administrator privileges can run the docker command. For security reasons, you don't want to use root users or sudo to run Docker. To solve this problem, you need to add your own users to the docker group. The command is as follows:
Sudo usermod-a-G docker $USER
After completing the operation, log out of the system and then log in again, which should be done. However, if your platform is Fedora, you will find that this group does not exist when you add users to the docker group. What are we going to do? You need to create this group first. The command is as follows:
Sudo groupadd docker & & sudo gpasswd-a ${USER} docker & & sudo systemctl restart dockernewgrp docker
Log out and then log in. You can start using Docker.
Start, pause, and enable Docker
After installing Docker, you can have the system start the Docker daemon automatically at startup. Use the following two commands to do this:
Sudo systemctl start dockersudo systemctl enable docker
If you need to pause or restart the Docker daemon, the command is:
Sudo systemctl stop dockersudo systemctl restart docker
Now you can use Docker to deploy the container.
Pull the image
For Docker, mirroring is the cornerstone of building containers. You can pull down an image (such as NGINX) and deploy as many containers as you want based on that image. Before using a mirror, you first need to pull the image into the system. Images are pulled from the registry. By default, the installed Docker contains a default registry Docker Hub, which contains a large number of images contributed by others (including both official images and users' own images).
Suppose you want to pull an image related to the Nginx Web server. Before you start pulling, check which images are already in the system. Enter the docker images command and you will find that there is no mirror yet (figure 1).
Figure 1: no mirror image yet.
Let's pull a mirror image. Use the following command to download the Nginx image from Docker Hub:
Docker pull nginx
The above command downloads the (official) Nginx image from Docker Hub. Now run the docker images command again and you can see that the images are listed (figure 2).
The 2:NGINX image has been pulled down.
Did you notice that I'm talking about an "official" Nginx image? There are many unofficial Nginx images on Docker Hub. These unofficial images are created for a variety of purposes. You can search for all Nginx images in Docker Hub using the following command:
Docker search nginx
You'll find (in figure 3) that there are many Nginx images created for different purposes (reverse proxy, PHP-FPM (FastCGI process manager FastCGI Process Manager is a PHPFastCGI manager designed to integrate FastCGI process management into PHP packages), LetsEncrypt (LCTT: free SSL project provided by ISRG), Bitnami, Nginx and Drupal for raspberry pie, and many more).
Figure various NGINX images found on 3:Docker Hub.
Suppose you want to download a Nginx image with a built-in reverse proxy, with an unofficial image jwilder/nginx-proxy. So enter the following command to pull the image:
Docker pull jwilder/nginx-proxy
Type the docker images command again to view the newly pulled image (figure 4).
Figure 4: there are already two different NGINX images.
As a matter of caution, I suggest using only official images. After all, you can't be sure whether unofficial images contain malicious code.
Thank you for your reading, the above is the content of "how to install and use Docker on Linux". After the study of this article, I believe you have a deeper understanding of how to install and use Docker on Linux. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.