Docker installation and use
#如果你之前安装过 Docker, please erase the
sudo yum remove docker docker-common docker-selinux docker-engine
#安装一些依赖
sudo yum Install-y yum-utils device-mapper-persistent-data lvm2
#下载repo文件:
wget-o/etc/yum.repos.d/docker-ce.repo Https://download.docker.com/linux/centos/docker-ce.repo
#把软件仓库地址替换为 TUNA:
sudo sed-i ' s+ Download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+ '/etc/yum.repos.d/docker-ce.repo
#最后安装:
sudo yum makecache fast
sudo yum install docker-ce
#验证是否安装成功
docker-v
#显示Docker version 18.03.0-ce , build 0520e24
#启动docker
service Docker start
Configuring a domestic mirror
Vi/etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
# Restart Docker
systemctl daemon-reload
systemctl Restart Docker
#配置加速器之后, if the pull mirror is still very slow, manually check that the accelerator configuration is in effect, Execute Docker info at the command line, if the following is seen from the result, the configuration is successful.
Registry Mirrors:
https://registry.docker-cn.com/
Common Commands
1.docker pull CentOS Pull Docker Mirror (default is pulled from the official mirror warehouse, if pull do not come down, we suggest that Baidu switch domestic mirror warehouse)
2.docker run-p 8082:80-v/mnt/hgfs/public/:/mnt/hgfs/public/--name mycentos-it CentOS
To generate a new container from a mirror,
Where-P is the port mapping, the 8082 port of the host is mapped to 80 ports in the container.
-V is a disk mount that maps the/mnt/hgfs/public/in the host to the/mnt/hgfs/public/directory in the container.
–name is a name for this container.
Other available parameters:
-I: Run the container in interactive mode, usually with-t;
-T: Reassign a pseudo input terminal for the container, usually used concurrently with-I;
3.docker images display all local docker mirrors
4.docker PS Displays the currently running container (needs to see all containers plus-a parameter)
5.docker Stop Mycentos stops the currently running container
6.docker start Mycentos launch a container
7.docker attach Mycentos connected to a container (I understand that into the container)
8.docker exec-i-T Mynginx/bin/bash open an interactive mode terminal Other command in the container Mynginx
The other is not how to use, there is a need for students to come here to see
Docker command