docker使用实战(一)

版权声明:本文为博主原创文章,如需转载请注明出处 https://blog.csdn.net/linghuanxu/article/details/88937869

背景

虽然说,springboot让我可以暂时降低对docker的依赖,但是,这么多进程的管理,没有docker,环境的管理,进程的管理,还是非常费劲的。关于这些东西的管理,我的思路是引入kubernetes,但是,说实话我没用过,也不清楚它到底是什么。为了搞清楚kubernetes到底是什么,我决定先学docker。似乎这已经是一条无法避免的道路,那就让我们上路吧。

安装

这里我使用的操作系统是centos7,这里还是使用yum进行安装。首先添加对应的yum仓库,创建文件/etc/yum.repos.d/docker.repo,内容如下:

[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

yum install docker-engine -y 这就可以安装成功啦
  systemctl start docker 这样就运行起来了
  也可以使用docker version来查看当前的docker版本。我的版本信息如下:

Client:
 Version:      17.05.0-ce
 API version:  1.29
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:06:25 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.05.0-ce
 API version:  1.29 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:06:25 2017
 OS/Arch:      linux/amd64
 Experimental: false

运行第一个容器

上面我们已经通过systemctl start docker将docker服务运行起来了,接下来我们来运行第一个容器。
  docker run hello-world 这是docker内置的一个镜像,能运行成功,我们的docker的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/

猜你喜欢

转载自blog.csdn.net/linghuanxu/article/details/88937869
今日推荐