安装docker
1.安装docker
#dokcer 安装
yum remove -y docker docker-common docker-selinux docker-engine
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce -y
systemctl restart docker
systemctl enable docker
docker version
echo net.ipv4.ip_forward=1 >> /usr/lib/sysctl.d/00-system.conf
systemctl restart network && systemctl restart docker
2. 配置镜像加速器
针对Docker客户端版本大于 1.10.0 的用户
您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors" : [
"http://ovfftd6p.mirror.aliyuncs.com",
"http://registry.docker-cn.com",
"http://docker.mirrors.ustc.edu.cn",
"https://ybttr80n.mirror.aliyuncs.com",
"http://hub-mirror.c.163.com"
],
"insecure-registries" : [
"registry.docker-cn.com",
"docker.mirrors.ustc.edu.cn"
],
"debug" : true,
"experimental" : true
}
EOF
##其他
sudo systemctl daemon-reload
sudo systemctl restart docker
相关操作
更新中
不进容器操作命令
docker exec -it 容器名称 ls
docker exec -it 容器名称 /bin/bash
停止所有的容器
docker stop $(docker ps -aq)
查看日志
docker logs -f 容器名称
安装docker-compose(官网:https://github.com/docker/compose/releases)
curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose