Docker入门(2)-Docker安装

10 篇文章 0 订阅
9 篇文章 0 订阅

Ubuntu Docker 安装

Docker 支持以下的 Ubuntu 版本:

Ubuntu Precise 12.04 (LTS)

Ubuntu Trusty 14.04 (LTS)

Ubuntu Wily 15.10

其他更新的版本……

前提条件

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

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

edualiyun@edualiyun:~$ uname -r

使用脚本安装 Docker

1、获取最新版本的 Docker 安装包

edualiyun@edualiyun:~$ wget -qO- https://get.docker.com/ | sh

输入当前用户的密码后,就会下载脚本并且安装Docker及依赖包。

安装完成后有个提示:

在这里插入图片描述

当要以非root用户可以直接运行docker时,需要执行 sudo usermod -aG docker runoob 命令,然后重新登陆,否则会有如下报错

2、启动docker 后台服务

edualiyun@edualiyun:~$ sudo service docker start

3、测试运行hello-world

edualiyun@edualiyun:~$ docker run hello-world

CentOS Docker 安装

Docker支持以下的CentOS版本:

CentOS 7 (64-bit)

CentOS 6.5 (64-bit) 或更高的版本

前提条件

目前,CentOS 仅发行版本中的内核支持 Docker。

Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。

Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本。

使用 yum 安装(CentOS 7下)

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

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

[root@edualiyun ~]# uname -r 3.10.0-327.el7.x86_64

安装 Docker

Docker 软件包和依赖包已经包含在默认的 CentOS-Extras 软件源里,安装命令如下:

[root@edualiyun ~]# yum -y install docker

安装完成。

启动 Docker 后台服务

[root@edualiyun ~]# service docker start

测试运行 hello-world

[root@edualiyun ~]#docker run hello-world

由于本地没有hello-world这个镜像,所以会下载一个hello-world的镜像,并在容器内运行。

**

使用脚本安装 Docker

**
1、使用 sudo 或 root 权限登录 Centos。

2、确保 yum 包更新到最新

$ sudo yum update

3、执行 Docker 安装脚本。

$ curl -fsSL https://get.docker.com/ | sh

执行这个脚本会添加 docker.repo 源并安装 Docker。

4、启动 Docker 进程。

$ sudo service docker start

5、验证 docker 是否安装成功并在容器中执行一个测试的镜像。

$ sudo docker run hello-world

到此,docker 在 CentOS 系统的安装完成。

Windows Docker 安装

Docker 引擎使用的是 Linux 内核特性,所以我们需要在 Windows 上使用一个轻量级的虚拟机 (VM) 来运行 Docker。

我们通过 Boot2Docker 来安装虚拟机和运行 Docker
安装
1、安装Boot2Docker
最新版 Boot2Docker 下载地址: https://github.com/boot2docker/windows-installer/releases/latest

目前最新版为v1.8.0, 下载地址为: https://github.com/boot2docker/windows-installer/releases/download/v1.8.0/docker-install.exe

2、运行安装文件
运行安装文件,它将会安装 virtualbox、MSYS-git boot2docker Linux 镜像和 Boot2Docker 的管理工具。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
点击"Install"开始安装。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

从桌面上或者 Program Files 中运行 Boot2Docker Start。

Boot2Docker Start 将启动一个 Unix shell 来配置和管理运行在虚拟主机中的 Docker,我们可以通过运行 docker version 来查看它是否正常工作。

运行 Docker

使用boot2docker.exe ssh 连接到虚拟主机上,然后执行docker run hello-world
在这里插入图片描述
到此,docker在Windows系统的安装完成。
在这里插入图片描述

我的安装过程:
1.下载centOS7镜像,参考链接:https://blog.csdn.net/yxwmzouzou/article/details/78527331
下载地址:http://120.52.51.19/isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1810.iso

2.安装centOS7操作系统,可以参考:
https://www.osyunwei.com/archives/7829.html

3.系统初始配置
[root@localhost network-scripts]# systemctl stop firewalld.service
[root@localhost network-scripts]# systemctl disable firewalld.service
[root@localhost network-scripts]# cd /etc/selinux/
[root@localhost selinux]# ls
config final semanage.conf targeted tmp
[root@localhost selinux]# vi config
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# vi ifcfg-ens33
[root@localhost selinux]# systemctl restart network.service

4.配置yum源
https://www.cnblogs.com/renpingsheng/p/7845096.html

5.安装DOcker

[root@localhost yum.repos.d]# yum -y install docker

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

6.启动Docker服务

[root@localhost yum.repos.d]# service docker start

Redirecting to /bin/systemctl start docker.service
7.验证 docker 是否安装成功并在容器中执行一个测试的镜像

[root@localhost yum.repos.d]# docker run hello-world

Unable to find image ‘hello-world:latest’ locally Trying to pull
repository docker.io/library/hello-world … latest: Pulling from
docker.io/library/hello-world 1b930d010525: Pull complete Digest:
sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for docker.io/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/

[root@localhost yum.repos.d]#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值