[root@jinan ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest feb5d9fea6a5 6 weeks ago 13.3kB
# 解释 REPOSITORY 镜像的仓库源 TAG 镜像的标签 IMAGE ID 镜像的id CREATED 镜像的创建时间 SIZE 镜像的大小
#可选项 -a, --all # 列出所有镜像 -q, --quiet # 只显示镜像的 i
docker search 搜索镜像
1 2 3 4 5 6 7 8 9 10 11
[root@jinan ~]# docker search mysql NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 11635 [OK] mariadb MariaDB Server is a high performing open sou… 4429 [OK]
# 可选项,通过 收藏来过滤 -f STARS=5000 # 搜索出来的镜像就是 STARS大于5000的 [root@jinan ~]# docker search mysql -f STARS=5000 NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 11635 [OK]
[root@jinan /]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@jinan /]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 21c66a321a57 centos "/bin/bash" 3 minutes ago Exited (130) About a minute ago priceless_chaum adfe59459fc2 feb5d9fea6a5 "/hello" 2 hours ago Exited (0) 2 hours ago heuristic_lederberg [root@jinan /]#
[root@jinan ~]# docker ps -a -n=1 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5ad0ba439569 centos "/bin/bash" 4 minutes ago Exited (0) 3 minutes ago objective_ramanujan [root@jinan ~]#
[root@jinan ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d061dbe1843a centos "/bin/bash" 8 seconds ago Exited (0) 5 seconds ago affectionate_tesla
[root@jinan home]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 462a33b2341d centos "/bin/bash" 25 minutes ago Up 43 seconds hardcore_golick
attach Attach to a running container #当前she11 下attach 连接指定运行镜像 build Build an image from a Dockerfile #通过Dockerfile定制诡像 commit create a new image from a container changes #提交当前容器为新的镜像cp copy files/folders from the containers filesystem to the host path #从容器中拷贝指定文件或者目录到宿主机中 create Create a new container #创建一个新的容器,同run,但不启动容器 diff Inspect changes on a container‘s filesystem #查看docker容器变化 eventsGet real time events from the server #从docker服务获取容器实时事件 exec Run a command in an existing container #在已存在的容器上运行命令 export Stream the contents of a container as a tar archive #导出容器的内容流作为一个 tar归档文件[对应import ] history show the history of an image #展示一个镜像形成历史 images List images #列出系统当前镜像 import create a new filesystem image from the contents of a tarball #从tar包中的内容创建一个新的文件系统映像[对应export] info Display system-wide information #显示系统相关信息 inspect Return low-level information on a container #查看容器详细信息 ki11ki1l a running container #ki11指定docker容器 loadLoad an image from a tar archive #从一个tar包中加载一个镜像[对应save] login Register or Login to the docker registry server#注册或者登陆一个docker 源服务器 logoutLog out from a Docker registry server #从当前Docker registry退出 logsFetch the logs of a container #输出当前容器日志信息 port Lookup the public-facing port which is NAT-ed to PRTVATE_PORT#查看映射端口对应的容器内部源端口 pausePause a11 processes within a container #暂停容器 ps List containers #列出容器列表 pull pull an image or a repository from the docker registry server# 从docker镜像源服务器拉取指定镜像或者库镜像 push Push an image or a repository to the docker registry server#推送指定镜像或者库镜像至docker源服务器 restart Restart a running container #重启运行的容器 rm Remove one or more containers #移除一个或者多个容器 rmi Remove one or more images #移除一个或多个镜像[无容器使用该镜像才可刷除,否则需删除相关容器才可继续或-f强制删除] run Run a command in a new container #创建一个新的容器并运行一个命令 save save an image to a tar archive #保存一个镜像为一个tar包[对应1oad] search search for an image on the Docker Hub #在docker hub中搜索镜像 start start a stopped containers #启动容器 stop Stop a running containers #停止容器 tag Tag an image into a repository #给源中镜像打标签 top Lookup the running processes of a container #查看容器中运行的进程信息 unpause Unpause a paused container #取消暂停容器 version show the docker version information #查看docker版本号 wait Block until a container stops,then print its exit code#截取容器停止时的退出状态值
UnionFS ( 联合文件系统):Union文件系统( UnionFS )是一种分层、轻量级并且高性能的文件系统,它支持对文件系统的修改作为一次提交来一层层的叠加,同时可以将不同目录挂载到同一个虚拟文件系统下(unite several directories into a single virtualfilesystem)。Union文件系统是Docker镜像的基础。镜像可以通过分层来进行继承,基于基础镜像(没有父镜像),可以制作各种具体的应用镜像。
Log in to a Docker registry. If no server is specified, the default is defined by the daemon.
Options: -p, --password string Password --password-stdin Take the password from stdin -u, --username string Username [root@jinan test]#
登录账号
1 2 3 4 5 6 7 8
[root@jinan test]# docker login -u jinan6 Password: WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded [root@jinan test]#
登录完成之后 docker push 命令发布镜像
问题:发布时,提示镜像不存在,拒绝push等情况
1 2 3 4
The push refers to repository [docker.io/jinan/diytomcat] An image does not exist locally with the tag: jinan/diytomcat
denied: requested access to the resource is denied
[root@jinan ~]# docker network ls NETWORK ID NAME DRIVER SCOPE aa9b860284dd bridge bridge local 3a264c67de20 host host local 52b4382173d1 none null local
网络模式
bridge:桥接 docker(默认自己创建也使用桥接模式)
none:不配置网络
host:和宿主机共享网络
测试
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# 我们直接启动的命令 --net bridge,而这个就是我们的docker0 docker run -d -P tomcat01 tomcat docker run -d -P tomcat01 --net brige tomcat
# docker0 的特点:默认,ip不能访问,--link可以打通连接
# 自定义一个网络 # --driver bridge # --subnet 192.168.0.0/16 # --gateway 192.168.0.1 [root@jinan ~]# docker network create --driver bridge --subnet 192.168.0.0/16 --gateway 192.168.0.1 mynet 24bf902d70d6ebb16d43c94a557b4a7d488d3ad17c54169ede8f1b68a43186f6 [root@jinan ~]# docker network ls NETWORK ID NAME DRIVER SCOPE aa9b860284dd bridge bridge local 3a264c67de20 host host local 24bf902d70d6 mynet bridge local 52b4382173d1 none null local [root@jinan ~]#