Ubuntu 下安装Docker小结

这几天一直在折腾ubuntu下安装docker——webRTC service 需要在Docker环境下才能运行,网上的资料有的是存在问题的,会受限于当前ubuntu的版本。本人的ubuntu版本为:

uname -r

Linux server 3.16.0-30-generic #40~14.04.1-Ubuntu SMP Thu Jan 15 17:43:14 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

在安装了最新的docker,之后一直出问题。

docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: 
starting container process caused "process_linux.go:297: 
copying bootstrap data to pipe caused \"write init-p: broken pipe\"": unknown.

看了帖子说是ubuntu版本过低,需要升级ubuntu版本。shit,我就安装个工具你让我更新系统版本?结果很多帖子都说是系统版本太低,无法使用当前版本的docker。能不能将docker版本降低?

sudo apt-cache madison docker-ce

 docker-ce | 18.06.3~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 18.06.2~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 18.06.1~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 18.06.0~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 18.03.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.12.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.12.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.09.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.09.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.06.2~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.06.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.06.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.03.2~ce-0~ubuntu-trusty | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.03.1~ce-0~ubuntu-trusty | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages
 docker-ce | 17.03.0~ce-0~ubuntu-trusty | https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages

我选择的是 17.12.1~ce-0~ubuntu

贴上完整操作步骤(前面一部分是第一次安装docker时的命令)

第一部分

1.更新Ubuntu的apt源索引

$ sudo apt-get update
2.安装包允许apt通过HTTPS使用仓库

$ sudo dpkg --configure -a
$ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
3.添加Docker官方GPG key


$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

4.设置Docker稳定版仓库

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
5.更新apt源索引


$ sudo apt-get update
6.安装最新版本Docker CE(社区版)

$ sudo apt-get install docker-ce

查看安装Docker的版本

$ docker --version
检查Docker CE 是否安装正确

$ sudo docker run hello-world

到此会因为docker版本过高导致无法运行hello-world

因此第二部分的步骤为:

卸载docker-ce
sudo apt-get autoremove docker-ce
显示稳定可使用版本
sudo apt-cache madison docker-ce
安装稳定版本
sudo apt-get install docker-ce=17.12.1~ce-0~ubuntu

成功后再运行:sudo docker run hello-world


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/

至此,docker安装成功,版本为:Docker version 17.12.1-ce, build 7390fc6

最后贴上基本的docker指令

# 启动docker
sudo service docker start

# 停止docker
sudo service docker stop

# 重启docker
sudo service docker restart

# 列出镜像
docker image ls

# 拉取镜像
docker image pull library/hello-world

# 删除镜像
docker image rm 镜像id/镜像ID

# 创建容器
docker run [选项参数] 镜像名 [命令]

# 停止一个已经在运行的容器
docker container stop 容器名或容器id

# 启动一个已经停止的容器
docker container start 容器名或容器id

# kill掉一个已经在运行的容器
docker container kill 容器名或容器id

# 删除容器
docker container rm 容器名或容器id

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值