Docker安装
Docker安装
卸载旧版本
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
一键安装
curl -fsSL https://get.docker.com | bash -s docker --mirror aliyun
or
curl -sSL https://get.daocloud.io/docker | sh
# dockerd-rootless-setuptool.sh install
curl -sSL https://get.daocloud.io/docker | sh
systemctl restart docker
systemctl enable docker
systemctl status docker
换为国内源
cat > /etc/docker/daemon.json<<EOF
{
"registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com","https://docker.mirrors.ustc.edu.cn"]
}
EOF
cat >/etc/docker/daemon.json <<EOF
{
"registry-mirrors" : [
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn",
"https://cr.console.aliyun.com",
"https://mirror.ccs.tencentyun.com"
]
}
EOF
systemctl restart docker
#失败了可以查看错误并重置
journalctl -xe
systemctl reset-failed docker.service
xxxxxxxxxx docker-compose up -dbash
ymir就是我们要创建并添加到docker组的普通用户
useradd ymir
groupadd docker
gpasswd -a ymir docker
systemctl restart docker
docker登录
docker login -u edclol1 -p bsNHv8D6YCmF@ej
Docker-Compose
curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
增加远程连接
vim /etc/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
systemctl daemon-reload
systemctl restart docker
cat >/etc/yum.repos.d/docker-ce.repo <<'END'
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
END
yum clean all
yum makecache fast
yum install -y bash-completion
yum install -y yum-utils device-mapper-persistent-data lvm2
repoquery --show-duplicates docker-ce
yum install -y docker-ce-3:19.03.15-3.el7.x86_64
mkdir -p /etc/docker/
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"data-root": "/app/docker",
"registry-mirrors": ["https://4520m56w.mirror.aliyuncs.com"],
"insecure-registries":["192.168.123.8:5000","192.168.109.149:8090"],
"log-opts":{ "max-size" :"50m","max-file":"1"}
}
EOF
systemctl start docker
systemctl enable docker