安装Docker&Docker Compose

原创
2018/05/24 01:23
阅读数 71

Docker CE的安装参考文档

1 CentOS

操作系统版本

[root@centos7 ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 

1.1 卸载旧版本

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine

1.2 使用Repository安装

# 1
sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2
# 2
sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
# 3
sudo yum install docker-ce

# 4 安装特定版本
yum list docker-ce --showduplicates | sort -r
sudo yum install docker-ce-<VERSION STRING>
    

1.3 使用package安装

# 下载  https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm

# 安装
sudo yum isntall /path/to/package.rpm

1.4 验证与启动

sudo systemctl start docker
sudo docker run hello-world

1.5 升级

To upgrade Docker CE, download the newer package file and repeat the installation procedure, using yum -y upgrade instead of yum -y install, and pointing to the new file.

1.6 安装Docker Compose

https://docs.docker.com/compose/install/

# 1
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

# 2 
sudo chmod +x /usr/local/bin/docker-compose

# 3 
docker-compose --version

这里有一篇讲了通过Python-pip来安装的 https://www.cnblogs.com/YatHo/p/7815400.html

2 Mac

https://docs.docker.com/docker-for-mac/install/

待续...

3 Ubuntu

https://docs.docker.com/install/linux/docker-ce/ubuntu/

待续...

4 Docker加载镜像

修改/etc/docker/daemon.json文件,写入下而这行后,重启Docker生效

{
  "registry-mirrors": ["https://registry.docker-cn.com"]
}
展开阅读全文
打赏
0
1 收藏
分享
加载中
更多评论
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部