1.docker的安装
使用如下的命令直接使用yum进行默认安装
yum search docker
yum -y install docker-io
安装完成后,使用命令查看基本信息
docker -v
上面的命令会展示基本版本信息,不启动Docker服务也是可以查询的
使用docker --version可以看到更详细的信息,但是必须启动docker守护进程
如果没有启动守护进程,会提示如下信息
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Is the docker daemon running?
2.Docker守护进程的启动
使用如下命令可完成对Docker守护进程的启动
/bin/systemctl restart docker.service
启动完成后,使用docker --version 查看详细信息,展示信息如下
Client:
Version: 1.13.1
API version: 1.26
Package version: docker-1.13.1-103.git7f2769b.el7.centos.x86_64
Go version: go1.10.3
Git commit: 7f2769b/1.13.1
Built: Sun Sep 15 14:06:47 2019
OS/Arch: linux/amd64
Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Package version: docker-1.13.1-103.git7f2769b.el7.centos.x86_64
Go version: go1.10.3
Git commit: 7f2769b/1.13.1
Built: Sun Sep 15 14:06:47 2019
OS/Arch: linux/amd64
Experimental: false
3.创建简单image—hello-world
使用pull命令拉取镜像
docker pull library/hello-world
使用images命令查看已有镜像
docker images
如果存在镜像,将会展示如下信息
仓库 标签 镜像ID 创建时间 大小
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> f53db77df5c2 46 minutes ago 193 MB
docker.io/openjdk 8-alpine a3562aa0b991 6 months ago 105 MB
docker.io/hello-world latest fce289e99eb9 10 months ago 1.84 kB
使用run命令运行hello-world镜像
docker run hello-world
完成命令输入后,会在控制台上打印hello-world
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/