Skip to content

Instantly share code, notes, and snippets.

@sunny352
Last active April 1, 2024 06:51
Show Gist options
  • Save sunny352/221f3eb55bc2faa284192e72743fee54 to your computer and use it in GitHub Desktop.
Save sunny352/221f3eb55bc2faa284192e72743fee54 to your computer and use it in GitHub Desktop.
CentOS 7 安装 docker-ce 和 docker-compose 并设置腾讯云容器镜像源的脚本
#!/usr/bin/env bash
# 安装docker(使用阿里云源)
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce
systemctl start docker
# 迁移docker目录(可选)
systemctl stop docker docker.socket
mv /var/lib/docker /home/docker_lib
ln -s /home/docker_lib /var/lib/docker
systemctl enable docker
systemctl start docker
# 修改docker镜像源
mkdir /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
]
}
EOF
systemctl daemon-reload
systemctl stop docker docker.socket
systemctl start docker
# 安装Portainer容器管理工具(可选,需要访问http://localhost:9000进行配置)
docker run --name gui --restart always -d -p 9000:9000 -v "/var/run/docker.sock:/var/run/docker.sock" portainer/portainer-ce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment