In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
1. Install and configure Docker
Install Docker
First install the necessary dependency packages for Docker
[root@VM_1_64_centos ~] # cat / etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@VM_1_64_centos ~] #
[root@VM_1_64_centos ~] #
[root@VM_1_64_centos ~] #
[root@VM_1_64_centos ~] # yum install-y yum-utils device-mapper-persistent-data lvm2
Updated:
Device-mapper-persistent-data.x86_64 0RO 0.8.5-1.el7
Lvm2.x86_64 7vl 2.02.185-2.el7_7.2
Yum-utils.noarch 0VOR 1.1.31-52.el7
Dependency Updated:
Device-mapper.x86_64 7vl 1.02.158-2.el7_7.2
Device-mapper-event.x86_64 7vl 1.02.158-2.el7_7.2
Device-mapper-event-libs.x86_64 7vl 1.02.158-2.el7_7.2
Device-mapper-libs.x86_64 7vl 1.02.158-2.el7_7.2
Lvm2-libs.x86_64 7vl 2.02.185-2.el7_7.2
Python-urlgrabber.noarch 0RO 3.10-9.el7
Rpm.x86_64 0RO 4.11.3-40.el7
Rpm-build-libs.x86_64 0RO 4.11.3-40.el7
Rpm-libs.x86_64 0RO 4.11.3-40.el7
Rpm-python.x86_64 0RO 4.11.3-40.el7
Yum.noarch 0POS 3.4.3-163.el7.centos
Complete!
[root@VM_1_64_centos ~] #
Since we don't have Docker-CE with our own yum, we need to add docker repo first:
[root@VM_1_64_centos ~] # yum search all | grep docker
[root@VM_1_64_centos ~] #
[root@VM_1_64_centos ~] # yum-config-manager-- add-repo https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
Grabbing file https://download.docker.com/linux/centos/docker-ce.repo to / etc/yum.repos.d/docker-ce.repo
Repo saved to / etc/yum.repos.d/docker-ce.repo
[root@VM_1_64_centos ~] #
Install Docker with yum:
[root@VM_1_64_centos ~] # yum install-y docker-ce
Installed:
Docker-ce.x86_64 3Rank 19.03.4-3.el7
Dependency Installed:
Audit-libs-python.x86_64 0RO 2.8.5-4.el7
Checkpolicy.x86_64 0RO 2.5-8.el7
Container-selinux.noarch 2Vol 2.107-3.el7
Containerd.io.x86_64 0VOR 1.2.10-3.2.el7
Docker-ce-cli.x86_64 1Rank 19.03.4-3.el7
Libcgroup.x86_64 0RO 0.41-21.el7
Libseccomp.x86_64 0VR 2.3.1-3.el7
Libsemanage-python.x86_64 0RO 2.5-14.el7
Policycoreutils-python.x86_64 0RO 2.5-33.el7
Python-IPy.noarch 0RO 0.75-6.el7
Setools-libs.x86_64 0RO 3.3.8-4.el7
Dependency Updated:
Audit.x86_64 0RO 2.8.5-4.el7
Audit-libs.x86_64 0RO 2.8.5-4.el7
Libselinux.i686 0RO 2.5-14.1.el7
Libselinux.x86_64 0RO 2.5-14.1.el7
Libselinux-python.x86_64 0RO 2.5-14.1.el7
Libselinux-utils.x86_64 0RO 2.5-14.1.el7
Libsemanage.x86_64 0RO 2.5-14.el7
Libsepol.i686 0RO 2.5-10.el7
Libsepol.x86_64 0RO 2.5-10.el7
Policycoreutils.x86_64 0RO 2.5-33.el7
Selinux-policy.noarch 0VOR 3.13.1-252.el7.1
Selinux-policy-targeted.noarch 0VOR 3.13.1-252.el7.1
Complete!
View the version after successful installation
[root@VM_1_64_centos] # docker-v
Docker version 19.03.4, build 9013bf583a
[root@VM_1_64_centos ~] #
Set Boot self-boot
[root@VM_1_64_centos ~] # systemctl enable docker.service
Created symlink from / etc/systemd/system/multi-user.target.wants/docker.service to / usr/lib/systemd/system/docker.service.
[root@VM_1_64_centos ~] #
Configure Docker
Because domestic access to Docker Hub is slow, you can use the domestic image source provided by Tencent Cloud to accelerate access to Docker Hub.
Execute the following commands in turn
[root@VM_1_64_centos ~] # echo "OPTIONS='--registry-mirror= https://mirror.ccs.tencentyun.com'" > > / etc/sysconfig/docker
[root@VM_1_64_centos ~] # cat / etc/sysconfig/docker
OPTIONS='--registry-mirror= https://mirror.ccs.tencentyun.com'
[root@VM_1_64_centos ~] #
Reboot the modified daemon
[root@VM_1_64_centos ~] # systemctl daemon-reload
[root@VM_1_64_centos ~] # systemctl restart docker
[root@VM_1_64_centos ~] #
[root@VM_1_64_centos ~] # systemctl status docker
● docker.service-Docker Application Container Engine
Loaded: loaded (/ usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2019-11-12 18:32:11 CST; 7s ago
Docs: https://docs.docker.com
Main PID: 9286 (dockerd)
Memory: 41.1M
CGroup: / system.slice/docker.service
└─ 9286 / usr/bin/dockerd-H fd://-- containerd=/run/containerd/cont...
Nov 12 18:32:10 VM_1_64_centos dockerd [9286]: time= "2019-11-12T18:32:10.2274...c"
Nov 12 18:32:10 VM_1_64_centos dockerd [9286]: time= "2019-11-12T18:32:10.2274...c"
Nov 12 18:32:10 VM_1_64_centos dockerd [9286]: time= "2019-11-12T 18 purl 32 purl 10.4271..."
Nov 12 18:32:10 VM_1_64_centos dockerd [9286]: time= "2019-11-12T 18 purl 32 purl 10.8039..."
Nov 12 18:32:10 VM_1_64_centos dockerd [9286]: time= "2019-11-12T 18 purl 32 purl 10.9335..."
Nov 12 18:32:10 VM_1_64_centos dockerd [9286]: time= "2019-11-12T18:32:10.9419...2"
Nov 12 18:32:10 VM_1_64_centos dockerd [9286]: time= "2019-11-12T18:32:10.9421...4"
Nov 12 18:32:10 VM_1_64_centos dockerd [9286]: time= "2019-11-12T 18 purl 32 purl 10.9422..."
Nov 12 18:32:11 VM_1_64_centos systemd [1]: Started Docker Application Contai....
Nov 12 18:32:11 VM_1_64_centos dockerd [9286]: time= "2019-11-12T 18 purl 32 purl 11.1588..."
Hint: Some lines were ellipsized, use-l to show in full.
[root@VM_1_64_centos ~] #
Simple operation of 2.Docker
Download the image
Download an official CentOS image to local
[root@VM_1_64_centos ~] # docker pull centos
Using default tag: latest
Latest: Pulling from library/centos
729ec3a6ada3: Pull complete
Digest: sha256:f94c1d992c193b3dc09e297ffd54d8a4f1dc946c37cbeceb26d35ce1647f88d9
Status: Downloaded newer image for centos:latest
Docker.io/library/centos:latest
The downloaded image will appear in the image list.
[root@VM_1_64_centos ~] # docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Centos latest 0f3e07c0138f 5 weeks ago 220MB
Run the container
At this point, we can operate in the container generated by the CentOS image we just downloaded.
Generate a container with a centos image as a template and use bash shell
[root@VM_1_64_centos ~] # docker run-it centos / bin/bash
[root@649840f41e77 /] #
At this point, you can see that the front end of the command line has changed to [root@ (a string of hash Id)], which indicates that we have successfully entered the CentOS container.
Execute any command in the container without affecting the host, as follows
[root@649840f41e77 /] # mkdir-p / data/simple_docker
[root@649840f41e77 /] #
You can see that the simple_docker folder has been created successfully under the / data directory
[root@649840f41e77 /] # ls-l / data
Total 4
Drwxr-xr-x 2 root root 4096 Nov 12 10:34 simple_docker
[root@649840f41e77 /] #
Exit the container
[root@649840f41e77 /] # exit
Exit
[root@VM_1_64_centos ~] #
Check the / data directory of the host, and there is no simple_docker folder, indicating that the operations in the container will not affect the host.
[root@VM_1_64_centos ~] # ll / data
Total 0
[root@VM_1_64_centos ~] #
Save Container
Check all the container information and get the id of the container.
[root@VM_1_64_centos] # docker ps-a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
649840f41e77 centos "/ bin/bash" 2 minutes ago Exited (0) 58 seconds ago vigorous_banach
[root@VM_1_64_centos ~] #
Then execute the following command
, save the image:
[root@VM_1_64_centos ~] # docker commit-m = "test container 20191112" 649840f41e77
Sha256:92bf635d09941b79558c62c1940ed4a707091d83d26595624cf8bb62b69e28e3
[root@VM_1_64_centos ~] # docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
92bf635d0994 3 seconds ago 220MB
Centos latest 0f3e07c0138f 5 weeks ago 220MB
[root@VM_1_64_centos ~] #
It is built like a tag.
[root@VM_1_64_centos ~] # docker tag 92bf635d0994 centos02
[root@VM_1_64_centos ~] # docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Centos02 latest 92bf635d0994 48 seconds ago 220MB
Centos latest 0f3e07c0138f 5 weeks ago 220MB
[root@VM_1_64_centos ~] #
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.