一、docker的简介?
docker是一个开源的应用容器引擎,适用于微服务。目的是为了简化打包和项目部署。
二、docker五个重要组件?
客户端(docker client):docker的命令行交互界面。
服务端(docker daemon):用来响应dockerclient的请求。
容器(contains):运行镜像之后,实例化为容器,每个容器之间相互隔离,运行不同的应用。只读的文件层+可读可写文件层。
镜像(images):创建docker容器。联合文件系统(Union File System),由一些只读的文件层组成,每个文件层指向下一层。
仓库(repositorys):主要是用来存放镜像的仓库。
三、docker相关命令
docker pull [option] NAME[:TAG]--拉取镜像,TAG为版本号
docker images [options] [REPOSITORY[:TAG]]--查看服务器有哪些镜像,查看某一个镜像,REPOSITORY为镜像名,TAG为版本号
docker run [options] IMAGE[:TAG] [COMMAND][ARG...]--运行镜像
四、docker查看容器日志,查看contains容器的最近1000行日志
#查看1000行日志
[root@localhost software]# sudo docker logs -f -t --tail 1000 contains
#查看日志
[root@localhost software]# docker logs -f container
五、查找镜像,拉取镜像,查看本机镜像,运行镜像
#查询nginx有哪些镜像
[root@localhost /]# docker search nginx
#拉取nginx的镜像,默认拉取的版本是latest
[root@localhost /]# docker pull nginx
#查询本机有哪些镜像
[root@localhost /]# docker images
#运行镜像,-p映射端口:宿主机:容器;-d后台运行;nginx:latest运行的CONTAINER_NAME;mynginx:另取名
[root@localhost /]# docker run -p 80:80 --name mynginx -d nginx:latest
六、容器相关的命令
#暂停容器
[root@localhost /]# docker stop CONTAINER_NAME
#删除容器
[root@localhost /]# docker rm CONTAINER_NAME
#强制删除容器
[root@localhost /]# docker rm -f CONTAINER_NAME
#进入容器
[root@localhost /]# docker exec -it CONTAINER_NAME bash
#退出容器
9425eace6ed9: exit
#查看查看所有的容器,运行的和未运行的
[root@localhost /]# docker ps
[root@localhost /]# docker ps -a
七、docker run的执行过程?
docker client和docker daemon都是在本机。docker daemon会检查本机是否有镜像存在。
1.(docker client)-->(docker daemon)#查看本机是否有镜像
2.(docker daemon) pulled ("hello-world" image) from (Repository)
3.(docker daemon) create (container) which runs exucutable file from ("hello-world" image)
4.(docker daemon) streamed output to (docker client) which send to (terminal)