Install the Docker engine
Docker engine is the core component of Docker container. Docker engine is provided by Docker Desktop on MAC and Win10, and is provided by Docker Server on Linux.
Centos install Docker Server
The resources
A prerequisite for
Operating System Requirements
- Only CentOS 7 and CentOS 8 are supported
- Must be enabled
centos-extras
The repository. This repository is enabled by default, but you need to re-enable it if it has been disabled.
You can use yum Repolist [all] to list enabled libraries or all of them
$ yum repolist Loaded plugins: fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast Loading mirror speeds from cached hostfile * nux-dextop: li.nux.ro repo id repo name status ! 7 / base/x86_64 CentOS - 7, 10072! epel/x86_64 Extra PackagesforEnterprise Linux 7 - X86_64 13 604! extras/7/x86_64 CentOS-7 498 ! nux-dextop/x86_64 Nux.Ro RPMsforGeneral Desktop Use 2,724! Updates /7/x86_64 centos-7,458 repolist: 29,356Copy the code
- It is recommended to use
overlay2
Storage driver.
Uninstall the previous version
Older versions of Docker were called Docker or Docker-Engine. If these are installed, uninstall them and their associated dependencies.
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
Copy the code
Keep /var/lib/docker-/ content, including images, containers, volumes, and networks. The Docker engine package is now called Docker-CE.
installation
The following ways can be more self-selecting
-
Docker repository and install from it for later installation and upgrade tasks. This is the recommended method.
-
Download the RPM package to manually install and later manually manage the upgrade, which is useful on some air gap systems that do not have access to the Internet.
It was never mentioned in air Gapped, the separation of a computer from the Internet and from any computer connected to it.
-
In test and development environments, it is also appropriate to install Docker using automated, convenient scripts.
Install using a repository
Setting up the repository
Install the yum-utils package, which provides the yum-config-manager utility, and set up the stable repository.
Yum install -y yum-utils: yum install -y yum-utils: yum install -y yum-utils: yum install -y yum-utils: yum install -y yum-utils: yum install -y yum-utils: yum install -y yum-utils: yum install -y yum-utils: yum install -y yum-utils: yum install -y yum-utils: yum install -y yum-utils
$ sudo yum install -y yum-utils
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
Copy the code
Install the Docker engine
- Install the latest versions of Docker Engine and Containerd
$ sudo yum install docker-ce docker-ce-cli containerd.io
Copy the code
If you are prompted to accept the GPG key, check whether the fingerprint matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35. If yes, accept the GPG key.
-
To install a specific version of the Docker Engine, list the available versions in the repo, then select and install:
A. List and sort the versions available in the current repository. This example sorts the results by version number, from highest to lowest, and is truncated:
[root@zjlyyq yum.repos.d]# yum list docker-ce --showduplicates | sort -r * nux-dextop: li.nux.ro Loading mirror speeds from cached hostfile Loaded plugins: fastestmirror Installed Packages docker-ce.x86_64 3:20.10.8-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.8-3.el7 @docker-ce-stable docker-ce.x86_64 3:20.10.7-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-stable . . . . . . . . . docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable Available Packages Copy the code
B. Install a specific version
$ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io Copy the code
-
Start the Docker
$ sudo systemctl start docker Copy the code
-
validation
[root@zjlyyq ~]# sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world b8dfde127a29: Pull complete Digest: sha256:0fe98d7debd9049c50b597ef1f85b7c1e8cc81f59c8d623fcb2250e8bec85b38 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. Copy the code
Install using the RPM package
Install using a convenient script
10 to install Windows
System requirements
WSL 2 backend
- Windows 10 64-bit: Home or Pro 2004 (Build 19041) or later, or Enterprise or Education 1909 (Build 18363) or later.
- Enable WSL 2 on Windows.
- Download and install the Linux kernel update package.
The company computer is the enterprise version, the version is relatively low, forcibly open Docket Desktop will be the following effect.
Use Docker images
Download mirror
Command:
docker pull [OPTIONS] NAME[:TAG|@DIGEST]
Options:
-a, --all-tags Download all tagged images in the repository
--disable-content-trust Skip image verification (default true)
--platform string Set platform if server is multi-platform capable
-q, --quiet Suppress verbose output
Copy the code
Example:
Download the Ubuntu 18.04 image and use itDocker pull ubuntu: 18.04
Agent to accelerate
You can add –registry-mirror=proxy_URL to the Docker startup configuration to specify the address of the proxy server (e.g., registry.docker-cn.com).
Viewing Mirror Information
docker inspect ...
Create a mirror image
There are three ways to create an image: from an existing image container, from a local template to an import, and from a Dockerfile.
Created based on an existing container
docker [container] commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
OPTIONS:
- -a, –author=””: indicates the author information
- -c, –change=[]: Dockerfile command executed at commit time
- -m, –message=””: submit the message
- -p, –pause=true: pauses container execution during submission
zjl@zjl:~$ sudo docker commit -m "test port mapping and add some static files" -a "zjl"4 d22dbb1f90 nginx: 0.0.1 sha256:570 f2403b4c4c749df0d86cb41e88f5daaacd1ac1e4bbe9804b26cd63e9aa2b4 ZJL @ ZJL: ~ $sudo docker Images REPOSITORY TAG IMAGE ID CREATED SIZE nginx 0.0.1 570f2403b4C4 19 seconds ago 139MB nginx latest DD34e67e3371 2 days ago 133MB zjl@zjl:~$Copy the code
Import based on local templates
docker [image] import [OPTIONS] file|URL|-[REPOSITORY[:TAG]]
Create from Dockerfile
Docker is a text file that describes the process of creating a new image based on a parent image with a given instruction.
Image save and load
Docker [image] Save and docker [image] load
e.g.
Save for
load
Docker load < nginx_0. 0.1. The tar
Upload the image
- Add a TAG to the image to be uploaded.
Sudo docker tag nginx: 0.0.1${YOUR DOCKER USERNAME}/ nginx: 0.0.1Copy the code
- push
sudo docker push ${YOUR DOCKER USERNAME}/ nginx: 0.0.1Copy the code
The resources
- Docs.docker.com/config/daem…
- Stackoverflow.com/questions/5…