In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to install Docker in Centos7". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1 、 Centos 7 install docker-ce
Install the specified version of Docker-CE:
# Step 1: find the version of Docker-CE:
# yum list docker-ce.x86_64-- showduplicates | sort-r
* updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Installed Packages
* extras: mirrors.aliyun.com
* epel: mirrors.ustc.edu.cn
Docker-ce.x86_64 3Rank 18.09.0-3.el7 docker-ce-stable
Docker-ce.x86_64 3rig 18.09.0-3.el7 @ docker-ce-stable
Docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
Docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
Docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
Docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
Docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
Docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
Docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
Docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
Docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
Docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
Docker-ce.x86_64 17.06.0.ce-1.el7.centos 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
* base: mirrors.cqu.edu.cn
Available Packages
# Step2: install the specified version of Docker-CE
# sudo yum-y install docker-ce- [VERSION]
Install the latest version of Docker-CE:
# step 1: install some necessary system tools
Yum install-y yum-utils device-mapper-persistent-data lvm2-y
# Step 2: add software source information
Yum-config-manager-- add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: update and install Docker-CE
Yum makecache fast
Yum-y install docker-ce
# Step 4: enable Docker service
Systemctl start docker.service
Step 5: view the Docker installation version
Docker-version
Docker version 18.09.0, build 4d60db4
2. Docker installation directory structure
3. Start and stop mirroring
3.1. Launch the container
Custom image name: easy to distinguish
-d running in the background
Specify the name of the host boot
[root@centos7 ~] # docker run-itd-h hostname image
For example:
[root@centos7 ~] # docker run-itd docker.io/ubuntu / bin/bash
Root@82f8b90c9eba:/#
3.2. stop / exit, docker exit the container, and close the container
Exit
Docker exits the container without closing the container:
Ctrl+p ctrl+q / / here are two steps
Ctrl+p+q
Docker maps the local port to the running container
[root@centos7] # docker run-itd-p 0.0.0.0 name apache docker.io/ubuntu 80-- name apache docker.io/ubuntu / bin/bash
4. Docker common commands and explanations are as follows
Docker search nginx / / search Mirror Library
Docker pull nginx / / Select the appropriate image and pull the image
Docker images nginx / / find the image whose REPOSITORY is nginx in the local image list
Docker images httpd / / find the image whose REPOSITORY is apache in the local image list
Docker info / / View docker information
Docker version / / View docker version
Docker pull image name / / download (pull) image
Docker push image name / / upload image
Docker load-I image name. Tar / / Import image
Docker images / / View the list of all installed images
Docker attach image name / image ID / / enter the image
Docker exec image name / image ID ls / home / / execute the shell command into the container
For example: a.txt b.txt is the two text files I started to create.
[root@centos7 ~] # docker exec elegant_bhaskara ls / home
A.txt
B.txt
[root@centos7 ~] # docker stop image name / image ID / / stop mirroring
[root@centos7 ~] # docker tag original image name new image name / / generate a new images
For example: docker tag docker.io/ubuntu ubuntu:laste
[root@centos7 ~] # docker run-it test:ubuntu / bin/bash
[root@centos7 ~] # docker commit hopeful_carson (NAMES) ubuntu (REPOSITORY): self (tag) / / submit the image to generate a new image, and the configuration in the image is retained to facilitate the management of multiple versions
[root@centos7 ~] # docker run-itd-- name test01_self ubuntu:self starts a new image with the submitted image
0f280fd95659c81fcff4069bb53ff53b07d06b28de05111dd5a9177e16865f22
[root@centos7 ~] # docker exec test01_self ls / home
5. Submit the running container as an image (so that various operations in the container will not be lost)
[root@centos7 ~] # docker commit clever_haibt clever_haibt_new
# clever_haibt (running container name) clever_haibt_new (generated image name)
6. Run the image and add the port
[root@centos7] # docker run-d-it-p 80:80 clever_haibt_new:latest / bin/bash
# small p is a custom port latest is an image label (it is best to write it professionally)
Give an example of apache:httpd:latest
# docker run-d-it-p 80:80 httpd:latest
Test: http://ip
7. List the running images
[root@centos7 ~] # docker ps / / View the status of running containers
View the space occupied by images, containers, and data volumes
[root@centos7 ~] # docker system df
8. Docker itself provides two ways to terminate the operation of the container. Check the help.
[root@centos7] # docker stop-- help
For example: docker stop NAMES
Docker kill-help
9. Solve the problem that the public network is inaccessible after the docker port is mapped to the host in linux?
Solution:
[root@centos7 ~] # vim / etc/sysctl.conf
Or
[root@centos7 ~] # vim / usr/lib/sysctl.d/00-system.conf
Add the following code:
Net.ipv4.ip_forward=1
Restart the network service
# systemctl restart network
Check to see if the modification is successful
# sysctl net.ipv4.ip_forward
If returned as "net.ipv4.ip_forward = 1"
It means it's a success.
10. Delete the image
Stop mirroring first-- then perform delete operation
[root@centos7 ~] # docker rm image name / container ID
[root@centos7 ~] # docker rm-f Image name / Container ID / / Force deletion of Image
11. Export the image and generate the tar package. Export exports the file system of the read-write layer.
[root@centos7 ~] # docker export image name / image ID > XXXX.tar
For example:
[root@centos7 ~] # docker export test01_self > test01.tar
Export full image: save: export all files and history of the image
[root@centos7 ~] # docker save docker.io/imagine10255/centos6-lnmp-php56 > lnmp.tar
12. Import the image
[root@centos7 ~] # docker import test01.tar (mirror package) ubuntu:self_new (new image name)
13. Start the imported image
[root@centos7] # docker run-itd-- name ubuntu_self_new ubuntu:self_new / bin/bash
The file created before packaging exists
Import full image: load
[root@centos7 ~] # docker rmi docker.io/imagine10255/centos6-lnmp-php56 / / Delete
[root@centos7 ~] # docker load-I lnmp.tar / / re-import
This is the end of the content of "how to install Docker in Centos7". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.