- 1、docker Images 查看docker 本地镜像
- 2、docker pull 拉取镜像
- 3、docker ps 查看docker中运行的容器
- 4、docker run 启动容器
- 5、命令列表
[lsy@lsyPro /etc ]$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE rabbitmq latest 32497bcd639d 3 days ago 156MB
REPOSITORY: 仓库中镜像名称
TAG: 镜像的标签信息,比如 5.7、latest 表示不同的版本信息;
IMAGE ID:镜像的 ID, 如果您看到两个 ID 完全相同,那么实际上,它们指向的是同一个镜像,只是标签名称不同罢了;
CREATED:镜像最后的更新时间;
SIZE: 镜像的大小,优秀的镜像一般体积都比较小,这也是我更倾向于使用轻量级的 alpine 版本的原因;
[lxx@lsyPro /etc ]$ docker pull nginx Using default tag: latest latest: Pulling from library/nginx 69692152171a: Pull complete 49f7d34d62c1: Pull complete 5f97dc5d71ab: Pull complete cfcd0711b93a: Pull complete be6172d7651b: Pull complete de9813870342: Pull complete Digest: sha256:df13abe416e37eb3db4722840dd479b00ba193ac6606e7902331dcea50f4f1f2 Status: Downloaded newer image for nginx:latest docker.io/library/nginx:latest
说明
1、pull的镜像名称均为小写,可以在中央仓库中搜索到
2、 指定版本号
[lxxd@lsyPro /etc ]$ docker ps ConTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b1926a54a2e3 rabbitmq "docker-entrypoint.s…" 25 seconds ago Up 23 seconds 4369/tcp, 0.0.0.0:5672->5672/tcp, 5671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp rbmq4、docker run 启动容器
[lng@lsyPro /etc ]$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:5122f6204b6a3596e048758cabba3c46b1c937a46b5be6225b835d091b90e46c
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/
4.1 说明:
docker run先会去本地镜像仓库查找运行的镜像,找不到,则会去远程仓库拉取镜像,拉取完毕在运行镜像。
4.2 参数说明
| 参数 | 全称 | 说明 |
|---|---|---|
| -d | –detached==false | 指定容器运行于前台还是后台,默认为false( in background) |
| -h | –hostname="" | 指定容器的主机名 |
| –name | –name="" | 指定容器名字,后续可以通过名字进行容器管理,links特性需要使用名字 |
| -p | –publish=[] | (小写p)指定容器暴露的端口 |
docker run -i -t
docker run -d -it image_name 启动容器以后台方式运行(更通用的方式)
docker ps 列出当前所有正在运行的container
docker ps -a 列出所有的container
docker ps -l 列出最近一次启动的container
docker images 列出本地所有的镜像
docker rmi imagesID 删除指定的镜像id
docker rm ConTAINER ID 删除指定的ConTAINER id
docker diff 镜像名 查看容器的修改部分
docker kill ConTAINER ID 杀掉正在运行的容器
docker logs 容器ID/name 可以查看到容器主程序的输出
docker pull image_name 下载image
docker push image_name 发布docker镜像
docker version 查看docker版本
docker info 查看docker系统的信息
docker inspect 容器的id 可以查看更详细的关于某一个容器的信息
docker run -d image-name 后台运行镜像
docker search 镜像名 查找公共的可用镜像
docker stop 容器名/容器 ID 终止运行的容器
docker restart 容器名/容器 ID 重启容器
docker commit 提交,创建个新镜像
docker build [OPTIONS] PATH | URL | - 利用 Dockerfile 创建新镜像



