Docker(一) :安装docker

一,什么是Docker

“Docker is an open platform for developing, shipping, and running
applications.”

二,Docker能做什么?

"Docker provides the ability to package and run an application in a
loosely isolatedenvironment called a container. " "Containers are
lightweight becausethey don’t need the extra load of a hypervisor, but
run directly within the hostmachine’s kernel. This means you can run
more containers on a given hardwarecombination than if you were using
virtual machines. " “Docker provides tooling and a platform to manage the lifecycle of your containers: Develop your application
and its supporting components using containers. The container becomes
the unit for distributing and testing your application. When you’re
ready, deploy your application into your production environment,as a
container or an orchestrated service. This works the same whether
yourproduction environment is a local data center, a cloud provider,
or a hybridof the two.”
Docker(一) :安装docker_第1张图片

两个重要概念:
1,镜像IMAGES

An imageis a read-only template with instructions for creating a
Dockercontainer
. Often, an image isbased onanother image, with some
additionalcustomization. For example, you may build an image which is
based on theubuntuimage, but installs the Apache web server and your
application, as well as theconfiguration details needed to make your
application run.

2,容器CONTAINERS

A container is a runnable instance of an image. You can create, start,
stop,move, or delete a container using the Docker API or CLI. You can
connect acontainer to one or more networks, attach storage to it, or
even create a newimage based on its current state. By default, a
container is relatively well isolated from other containers andits
host machine. You can control how isolated a container’s network,
storage,or other underlying subsystems are from other containers or
from the hostmachine. A container is defined by its image as well as
any configuration options youprovide to it when you create or start
it. When a container is removed, any changes toits state that are not
stored in persistent storage disappear.

以上来自docker官方get-started

注:Docker与虚拟机的区别
Docker引擎所管理的容器与宿主机共享相同的内核,由于其隔离性应用在内核级别, 因此相对于虚拟机而言, 容器的运行并不会导致宿主机上的较大开销。无须虚拟化或模拟任何东西。
Docker(一) :安装docker_第2张图片

三,为什么要用Docker?

“Docker enables you to separate your applications from your infrastructure so you can deliver software quickly.”
在面对具有多个不同的操作系统、 操作系统的多个不同版本, 以及不同版本的库和编程语言的情况时, 设置能够持续提供一致体验的工作环境是非常必要的。

我其实是因为要了解“使用Docker容器来模拟由12台机器组成的网络实验环境,并通过镜像来安装脚本, 用来构建、 启动以及连接各容器。”这样一个过程,所以才有了这篇学习记录。

四,安装及换源

1,Install Docker Desktop on Windows
download from docker hub
期间可能会“遇到如下的错误提示,主要是windows版本不支持。

docker desktop requires windows 10 pro/Enterprise(15063+) or windows10 home (19018+)

解决办法有两个(个人建议用方法1):
1.升级系统版本
2.安装Docker Toolbox 安装教程

2,更改为国内镜像源
安装完成后查看docker信息:

docker info

检查Docker是否正常运行:

docker run hello-world

可能会出现net/http: TLS handshake timeout拉取镜像超时这个错误,是因为刚刚安装docker时,默认使用国外服务器,所以改成国内的镜像源就能解决。
运行docker desktop,按如下步骤添加国内源就行了,镜像源可以自行寻找并添加:
Docker(一) :安装docker_第3张图片
再执行:

docker run hello-world

Docker(一) :安装docker_第4张图片
结果如上,表明真正能用啦。

你可能感兴趣的:(Docker,docker)