ubuntu及centos安装指定版本docker

    xiaoxiao2022-07-15  146

    ubuntu及centos安装指定版本docker

    Ubuntu安装添加docker用户组,免sudo安装最新版本docker-compose Centos安装安装docker-compose

    Ubuntu安装

    推荐版本:

    Ubuntu Xenial 16.04[LTS]

    Ubuntu Trusty 14.04[LTS]

    要求:docker需要64位系统,kernel内核至少要在3.10版本之上。通过命令uname -r


    卸载系统上的老版docker源: sudo apt-get remove docker docker-engine docker-ce docker.io更新apt: sudo apt-get update安装下列包,是apt支持https: sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common添加Docker官方GPG密钥: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -国内源 中科大: curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add - 阿里云: curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - 官方源: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -设置stable存储库: sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"中科大源: sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"阿里源: sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"更新apt索引 sudo apt-get update查看已有的docker版本源 apt-cache madison docker-ce 选择需要安装的版本,docker-ce(社区版本)|版本字符串|存储地址|稳定特性 sudo apt-get install docker-ce=18.06.3~ce~3-0~ubuntu查看docker服务运行状态 systemctl status docker 重启docker sudo service docker restart sudo systemctl restart docker

    添加docker用户组,免sudo

    一般安装docker会自动创建docker用户组,如果没有创建,可通过下面命令创建: sudo groupadd docker加入当前用户 usermod -aG docker $USER重启sessions连接或重启 restart sessions(ssh) 或 sudo reboot ps: restart docker没用

    安装最新版本docker-compose

    进入github查看最新版本:https://github.com/docker/compose/releases sudo curl -L https://github.com/docker/compose/releases/download/1.23.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose赋予compose包执行权限 sudo chmod +x /usr/local/bin/docker-compose加快github的下载速度,查看该文章:

    https://blog.csdn.net/weixin_43819222/article/details/90499482

    查看compose版本 docker-compose --version

    Centos安装

    安装依赖包 um install -y yum-utils device-mapper-persistent-data lvm2添加docker软件包源 yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo关闭测试版本显示,只显示稳定版 yum-config-manager --enable docker-ce-edge yum-config-manager --enable docker-ce-test更新yum包索引 yum makecache fast安装指定版本 yum list docker-ce --showduplicates|sort -r|grep 'stable' 安装centos最新稳定版 yum install -y docker-ce-18.03.1.ce-1.el7.centos启动及查看版本 systemctl start docker docker version卸载 yum remove docker-ce rm -rf /var/lib/docker配置源地址 vi /etc/docker/daemon.json { "registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"] } 重新加载镜像源 systemctl daemon-reload

    安装docker-compose

    方法一: 安装 curl -L https://github.com/docker/compose/releases/download/1.23.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose查看compose版本 docker-compose --version 方法二: pip安装 yum install -y python-pip yum install -y python-devel pip install -i https://pypi.tuna.tsinghua.edu.cn/simple docker-compose报错 报错解决 pip install 'more-itertools<=5.0.0
    最新回复(0)