注意:centos7.2使用docker可能出现各自bug,最好用centos7.6+
1.1 安装工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
1.2 添加docker的yum库
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum makecache fast
1.3 安装Docker
sudo yum install docker-ce docker-ce-cli containerd.io
1.4 启动&开机启动
sudo systemctl start docker
sudo systemctl enable docker
1.5 Docker镜像加速器
vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://5pfmrxk8.mirror.aliyuncs.com"]
}
sudo systemctl daemon-reload //重新加载配置
sudo systemctl restart docker //重启docker
或者直接执行:
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://5pfmrxk8.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
测试docker
docker run hello-world
卸载docker
sudo yum remove docker-ce docker-ce-cli containerd.io
2.1. 下载docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
如果下载比较慢可以使用如下命令安装:
sudo curl -L https://get.daocloud.io/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
注意:上面的地址使用了占位符,是通过系统环境来决定URL,如果上面的方式都装不上,可以通过echo解析出真实的URL,通过浏览器下载安装如:
echo sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-Linux-x86_64 -o /usr/local/bin/docker-compose
或者:
拷贝:https://github.com/docker/compose/releases/download/1.24.1/docker-compose-Linux-x86_64在浏览器下载
然后上传到Linux “/usr/local/bin/docker-compose”目录即可
2.2 修改权限
sudo chmod +x /usr/local/bin/docker-compose
2.3. 创建软连接
sudo ln -s /usr/local/bin/docker-compose/docker-compose /usr/bin/docker-compose
2.4 查看版本
docker-compose --version
2.5. 卸载
sudo rm /usr/local/bin/docker-compose
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » docker与docker-compose安装
发表评论 取消回复