前提条件

Docker 要求 Ubuntu 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的 Ubuntu 版本是否支持 Docker。

通过 uname -r 命令查看你当前的内核版本

root@ranxf:/home/ranxf# uname -r
4.13.0-38-generic

使用脚本安装Docker

root@ranxf:/home/ranxf# wget -qO- https://get.docker.com/ | sh

下载脚本并且安装Docker及依赖包

root@ranxf:/home/ranxf# wget -qO- https://get.docker.com/ | sh
# Executing docker install script, commit: 92d5116
+ sh -c apt-get update -qq >/dev/null
+ sh -c apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | apt-key add -qq - >/dev/null
+ sh -c echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial edge" > /etc/apt/sources.list.d/docker.list
+ [ ubuntu = debian ]
+ sh -c apt-get update -qq >/dev/null
+ sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null
+ sh -c docker version
Client:
Version: 18.04.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 3d479c0
Built: Tue Apr 10 18:20:32 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm Server:
Engine:
Version: 18.04.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.4
Git commit: 3d479c0
Built: Tue Apr 10 18:18:40 2018
OS/Arch: linux/amd64
Experimental: false
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like: sudo usermod -aG docker your-user Remember that you will have to log out and back in for this to take effect!

安装完成后有个提示:当要以非root用户可以直接运行docker时,需要执行 sudo usermod -aG docker runoob 命令,然后重新登陆

WARNING: Adding a user to the "docker" group will grant the ability to run
containers which can be used to obtain root privileges on the
docker host.
Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
for more information.

2、启动docker 后台服务

root@ranxf:/home/ranxf# service docker start
root@ranxf:/home/ranxf#
root@ranxf:/home/ranxf# ps -ef |grep docker
root 474 1 0 14:28 ? 00:00:01 /usr/bin/dockerd -H fd://
root 481 474 0 14:28 ? 00:00:01 docker-containerd --config /var/run/docker/containerd/containerd.toml
root 2103 18769 0 14:41 pts/12 00:00:00 grep --color=auto docker
root@ranxf:/home/ranxf#

3、测试运行hello-world

root@ranxf:/home/ranxf# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
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/engine/userguide/

你可能想核对一下 docker 版本:

root@ranxf:/home/ranxf# docker version
Client:
Version: 18.04.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 3d479c0
Built: Tue Apr 10 18:20:32 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm Server:
Engine:
Version: 18.04.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.4
Git commit: 3d479c0
Built: Tue Apr 10 18:18:40 2018
OS/Arch: linux/amd64
Experimental: false

现在,docker 已经安装在您的系统上。

镜像加速:

如果要配置 Docker 守护进程默认使用 Docker 官方镜像加速。可以在 Docker 守护进程启动时配置 --registry-mirror 参数。

通过命令行启动Docker

docker --registry-mirror=https://registry.docker-cn.com daemon

通过配置文件启动Docker

Docker 版本在 1.12 或更高

修改 /etc/docker/daemon.json 文件并添加上 registry-mirrors 键值(没有该文件的话,请先建一个)。

鉴于国内网络问题,后续拉取 Docker 镜像十分缓慢,我们可以需要配置加速器来解决,如:网易的镜像地址

{
"registry-mirrors":["http://hub-mirror.c.163.com"]
}

从 Docker 库先下载 Docker Image 制作的容器。

root@ranxf:/home/ranxf# docker run ubuntu:15.10 /bin/echo "Hello world"
Unable to find image 'ubuntu:15.10' locally
15.10: Pulling from library/ubuntu
7dcf5a444392: Downloading [====================================> ] 37.63MB/51.07MB
759aa75f3cee: Download complete
7dcf5a444392: Pull complete
759aa75f3cee: Pull complete
3fa871dc8a2b: Pull complete
224c42ae46e7: Pull complete
Digest: sha256:02521a2d079595241c6793b2044f02eecf294034f31d6e235ac4b2b54ffc41f3
Status: Downloaded newer image for ubuntu:15.10

最新文章

  1. Java各种数据结构实现
  2. 《Entity Framework 6 Recipes》中文翻译系列 (23) -----第五章 加载实体和导航属性之预先加载与Find()方法
  3. 【Prince2是什么】PRINCE2认证之PRINCE2的思维结构
  4. iOS开发之多图片无缝滚动组件封装与使用
  5. Redis安装手册
  6. (旧)子数涵数·PS ——翻页效果
  7. VMware内安装Ubuntu后安装vmtools
  8. magento产品导入时需要注意的事项
  9. 云计算之阿里仓库停止openstack mitaka源报错“No package centos-release-openstack-mitaka available.”
  10. ceph -s集群报错too many PGs per OSD
  11. window模拟linux环境-cygwin安装
  12. SharedPreference映射Java类
  13. HTML5+CSS3(2)
  14. ADO.NET链接数据库封装方法
  15. 关于lampp中的proftpd的一些使用
  16. SITEMAP放到独立的文件上面
  17. PHP中文件类型 文件属性 路径以及 文件相关的函数
  18. TYVJ 1940 创世纪
  19. vim配置之tagbar
  20. CSS动画总结效果

热门文章

  1. ArcGIS GP应用-GP模型创建-缓冲区分析
  2. mybatis的一对多,多对一,以及多对对的配置和使用
  3. MyBatis映射示例
  4. POJ3660 传递闭包———floyd算法
  5. 在nginx启动后,如果我们要操作nginx,要怎么做呢 别增加无谓的上下文切换 异步非阻塞的方式来处理请求 worker的个数为cpu的核数 红黑树
  6. 微信开发 获取用户openId 与路由控制
  7. kafka Detailed Replication Design V3
  8. phpstrom 常用默认快捷键
  9. JMeter场景运行(非GUI方式运行命令)
  10. 【opencv】ubuntu opencv imshow()报错