Docker 入门实战一(了解docker和安装)

版权声明:本文为博主(wisdom-chen)的原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38423105/article/details/85380871

什么是Docker?

Docker 是一个开源的应用容器引擎,用Go语言并遵从Apache2.0协议开源。一次封装到处使用。

Docker的优点:

  1. 持续部署与测试(统一环境)
  2. 可移植性
  3. 环境标准化和版本控制(docker提供tag和version来控制版本)
  4. 隔离性(容器与容器之间相互独立)
  5. 安全性

Docker 分2大版本,CE(社区版)和 EE(企业版)

Docker quick start

前提:linux环境 centos7.0  没有安装过docker

先安装镜像仓库

1 安装所需的软件包yum-utils 提供了 yum-config-manager 实用程序,并且 devicemapper 存储驱动需要device-mapper-persistent-data 和 lvm2

 $ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

2 使用下列命令添加 stable 镜像仓库:

 $ sudo yum-config-manager \
     --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

安装Docker-ce

1 安装最新版本的 Docker CE

 $ sudo yum install docker-ce

2 启动docker 

 $ sudo systemctl start docker

3 设置后台默认启动docker

 $ systemctl enable docker

 4 验证是否正确安装了 docker,方法是运行 hello-world 镜像。

 $ sudo docker run hello-world

看到以下代码代表成功 Hello from Docker!

[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:b3a26e22bf55e4a5232b391281fc1673f18462b75cdc76aa103e6d3a2bce5e77
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/

5 查看docker版本

[root@localhost ~]# docker version
Client:
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:48:22 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:19:08 2018
  OS/Arch:          linux/amd64
  Experimental:     false

不会的命令可以通过docker --help 学习,

下一篇介绍docker的镜像操作命令和Dockerfile


参考文档:

Docker的五大优势:http://dockone.io/article/389

Docker官方快速入门文档:https://docs.docker-cn.com/engine/installation/linux/docker-ce/centos/

猜你喜欢

转载自blog.csdn.net/qq_38423105/article/details/85380871
今日推荐