美文网首页
docker 安装

docker 安装

作者: cyberhorse | 来源:发表于2018-02-13 23:19 被阅读0次

    系统 ubuntu 16.04

    1,添加docker源

    在 /etc/apt/source.list 最后加入:

    deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable

    2,sudo apt update

    3,sudo apt install docker-ce

    4,添加docker国内加速器

        可以用阿里云或者dao的,都需要注册,然后会分配一个唯一地址。如果不想注册的话,用我的也行:

        在 /etc/docker/daemon.json中删除原内容,加入

    {"registry-mirrors": ["https://cugt39s7.mirror.aliyuncs.com"]}

    然后执行:

        sudo systemctl daemon-reload

       sudo systemctl restart docker

    ****注意**** 如果使用公司网络,而公司网络通过代理上网,则可能不能成功加速。

    需要配置docker代理,方法如下:

    创建目录:

    mkdir -p /etc/systemd/system/docker.service.d

    创建文件:

    /etc/systemd/system/docker.service.d/http-proxy.conf

    在其中加入如下内容:

    [Service]

    Environment="HTTP_PROXY=http://代理ip:代理port" "HTTPS_PROXY=https://代理ip:代理port"

    重启docker服务

    sudo systemctl daemon-reload

    sudo systemctl restart docker

    5,将当前用户加入docker组,避免每次docker命令都要sudo

    sudo groupadd docker

    sudo gpasswd -a $USER docker

    退出当前用户(logout),然后再登录,就可以直接运行 docker xxx 啦

    6,验证安装:

    docker run hello-world

    将提示从阿里云下载helloworld镜像,并运行,结果类似:

    Unable to find image 'hello-world:latest' locally

    latest: Pulling from library/hello-world

    ca4f61b1923c: Pull complete

    Digest: sha256:66ef312bbac49c39a89aa9bcc3cb4f3c9e7de3788c944158df3ee0176d32b751

    Status: Downloaded newer image for hello-world:latest

    Hello from Docker!

    This message shows that your installation appears to be working correctly.

    相关文章

      网友评论

          本文标题:docker 安装

          本文链接:https://www.haomeiwen.com/subject/qnustftx.html