Docker HelloWorld

Docker服务

查看Docker服务状态

使用 systemctl status docker 命令查看 Docker 服务的状态。

haicoder(www.haicoder.net)# systemctl status docker

我们使用 systemctl status docker 命令查看 Docker 服务的状态,显示结果如下图所示:

01 docker status running.png

其中 Active: active (running) 即表示 Docker 服务为正在运行状态。

停止Docker服务

使用 systemctl stop docker 命令停止 Docker 服务。

haicoder(www.haicoder.net)# systemctl stop docker

此时再次使用 systemctl status docker 命令查看 Docker 服务的状态,显示结果如下图所示:

02 docker status stop.png

此时 Docker 服务的状态为 Active: inactive (dead) ,即停止状态。

启动Docker服务

使用 systemctl start docker 命令启动 Docker 服务。

haicoder(www.haicoder.net)# systemctl start docker

此时再次使用 systemctl status docker 命令查看 Docker 服务的状态,显示结果如下图所示:

03 docker status running.png

此时 Docker 服务的状态为 Active: active (running) ,即运行状态。

重启Docker服务

使用 systemctl restart docker 命令重启 Docker 服务。

haicoder(www.haicoder.net)# systemctl restart docker

下载Docker镜像(Images)

搜索Docker镜像(Images)

使用 docker search 命令从 Docker Repo 搜索 Dokcer 可用的镜像。

haicoder(www.haicoder.net)# docker search hello-world

我们使用 docker search 命令搜索名为 hello-world 的镜像,搜索结果如下图所示:

04 docker search helloworld.png

拉取Docker镜像(Images)

使用 docker image pull 命令从 Docker Repo 获取指定的 Dokcer镜像(Images)。

haicoder(www.haicoder.net)# docker image pull docker.io/hello-world

我们使用 docker image pull 命令拉取名为 docker.io/hello-world 的镜像,拉取结果如下图所示:

05 docker image pull.png

运行Docker镜像(Images)

查看Docker镜像(Images)

使用 docker image ls 命令查看本地的 Dokcer 镜像(Images)。

haicoder(www.haicoder.net)# docker image ls

我们使用 docker image ls 命令查看本地的 Dokcer 镜像(Images),本地镜像列表如下图所示:

06 docker image list.png

启动Docker镜像(Images)

使用 docker run 命令运行 Dokcer 镜像(Images)。

haicoder(www.haicoder.net)# docker run hello-world

我们使用 docker run 命令运行 Dokcer 镜像(Images),运行成功显示界面如下图所示:

07 docker helloworld.png