第一个docker命令 Docker Hello World

#docker run 镜像名

# docker run hello-world

Unable to find image 'hello-world:latest' locally

latest: Pulling from hello-world

b6d845cb453c: Pull complete

3535063d9957: Pull complete

Digest: sha256:135a30bd414bd8d23e386763e36f3dc4ee8ed25d2d6068082c0af796513d9d0d

Status: Downloaded newer image for hello-world:latest

 

如果镜像本机找不到会自己到docker.hub上面找

root@hsz:~# docker run ubuntu:15.10 /bin/echo "Hello world"

Unable to find image 'ubuntu:15.10' locally

15.10: Pulling from ubuntu

8e40f6313e6b: Pull complete

e2224f46fc07: Pull complete

8c721b8e6e1c: Pull complete

a73b3adec5de: Pull complete

bfaaabeea063: Pull complete

Digest: sha256:cc767eb612212f9f5f06cd1f4e0821d781a5f83bc24d1182128a1088907d3825

Status: Downloaded newer image for ubuntu:15.10

Hello world

root@hsz:~# docker run ubuntu:15.10 /bin/echo "Hello world"

Hello world

root@hsz:~#

各个参数解析:

docker: Docker 的二进制执行文件。

run:与前面的 docker 组合来运行一个容器。

ubuntu:15.10指定要运行的镜像,Docker首先从本地主机上查找镜像是否存在,如果不存在,Docker 就会从镜像仓库 Docker Hub 下载公共镜像。

/bin/echo "Hello world": 在启动的容器里执行的命令

以上命令完整的意思可以解释为:Docker 以 ubuntu15.10 镜像创建一个新容器,然后在容器里执行 bin/echo "Hello world",然后输出结果。

Docker优点:

第一个docker命令 Docker Hello World_第1张图片

#docker  version     //查看docker版本号

第一个docker命令 Docker Hello World_第2张图片

#docker info

第一个docker命令 Docker Hello World_第3张图片

更加详细的信息

# docker --help   //docker查看帮助

第一个docker命令 Docker Hello World_第4张图片

使用docker命令的用法格式:

Usage: docker [OPTIONS] COMMAND [arg...]

你可能感兴趣的:(docker)