1.安装依赖包
//1.安装依赖包
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
2.设置阿里云镜像源
//2.设置阿里云镜像
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3.安装docker-ce
//3.安装docker-ce,后续有是否确认操作,输入y
sudo yum install docker-ce
//如若出错Error: Failed to download metadata for repo 'docker-ce-stable': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried,修改镜像vim /etc/yum.repos.d/docker-ce.repo,[docker-ce-stable]中的baseurl修改为https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/stable
// 查看可用的版本: yum list docker-ce --showduplicates | sort -r
sudo yum install docker-ce-18.06.0.ce-3.el7
4.设置开机启动docker-ce
//4.设置docker可用,并启动docker服务
sudo systemctl enable docker
sudo systemctl start docker
5.安装docker-compose
//下载
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
//授权
sudo chmod +x /usr/local/bin/docker-compose
//查询docker-compose的版本号
docker-compose --version
6.docker启动/关闭
//启动应用
docker-compose up -d
//停止应用
docker-compose stop
//重启docker服务
sudo systemctl restart docker
//停止docker服务
sudo systemctl stop docker
//查看docker服务状态
sudo systemctl status docker
7.docker-compose找不到命令
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
8.docker-compose up -d报错
ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
用sudo docker-compose up -d试试
9.docker-reload daemon.json
sudo systemctl daemon-reload
sudo systemctl restart docker
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/92431.html