登录
    Technology changes quickly but people's minds change slowly.

ubuntu 下 docker 配置

技术宅 破玉 1329次浏览 0个评论

Ubuntu 安装 doker

apt 安装

sudo apt-get update

增加 https 支持

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

为 了 确认所下载软件包的合法性, 需要添加软件源的 GPG 密 钥 。

curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

添加国内源

sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $( lsb_release -cs) stable"

安装

sudo apt-get update
sudo apt-get install docker-ce

脚本自动安装

curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror Aliyun

启动docker

sudo service docker start

建立 docker 组:

sudo groupadd docker

将当前 用户加入docker 组

sudo usermod -aG docker $USER

退出终端重新登录后测试运行 docker

docker run hello-world

打印一下则成功

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:451ce787d12369c5df2a32c85e5a03d52cbcef6eb3586dd03075f3034f10adcd
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

配置国内镜像加速

在 /etc/docker/daemon. json 中 写 入如下内 容 (如果文件不存在,请新建该文件)

{
  "registry-mirrors": [
   "https://registry.docker-cn.com"
  ]
}

重启服务

sudo systemctl daemon-reload

拉取运行镜像

docker pull ubuntu:16.04
docker run -it  ubuntu:16.04  bash

列出已下载镜像:

docker image ls

华裳绕指柔, 版权所有丨如未注明 , 均为原创|转载请注明ubuntu 下 docker 配置
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址