docker常用命令详解
Posted llinux
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker常用命令详解相关的知识,希望对你有一定的参考价值。
docker search 在docker hub中搜索镜像;
1 [root@docker ~]# docker search lnmp 2 NAME DESCRIPTION STARS OFFICIAL AUTOMATED 3 twang2218/lnmp-nginx 这是 LNMP 示例中的 nginx 镜像 22 [OK] 4 winstonpro/lnmp based on ubuntu 14.04 20 5 dzer/lnmp lnmp环境 11 6 duckll/lnmp webservice 8 [OK] 7 2233466866/lnmp Systemd enabled. 8 8 fbraz3/lnmp An easy-to-use LNMP/LEMP image, with Ubuntu … 7 9 thinksvip/lnmp LNMP docker production environment 4 [OK] 10 maxwhale/lnmp-docker LNMP Docker 4 [OK] 11 twang2218/lnmp-php 这是 LNMP Docker 容器互联示例的 php 镜像 3 [OK] 12 evagle/lnmp ubuntu14.04 + nginx + mysql + php + redis 3 13 idiswy/lnmp Ubuntu 16.04 + nginx 1.8.x + php7 + MySQL 5.… 3 14 zhaojianhui/lnmp LNMP环境 1 15 c21xdx/lnmp13_cen6 php5.4 1 [OK] 16 turtlell/lnmp first lnmp demo 1 17 canj/lnmp lnmp环境(centos7+nginx+mariadb+php) 1 18 lyx554073858/lnmp docker hub link git hub 1 [OK] 19 inteye/lnmp LNMP1.2 (Linux, Nginx, Mysql, PHP). For deta… 1 20 dahaitech/lnmp-douyou douyou test lnmp 0 [OK] 21 huangguoji/lnmp lnmp.org的包 0 22 twang2218/lnmp-mysql This is the MySQL image of the LNMP docker c… 0 [OK] 23 zshtom/lnmp lnmp in centos 7 0 24 yahuiwong/lnmp linux nginx mysql php 0 [OK] 25 isntall/lnmp php fpm + extensions 0 [OK] 26 wildcloud/lnmpbase a basic lnmp for php app 0 27 tigerseye/lnmp for lnmp environment 0 [OK] 28
docker pull 从docker镜像源服务器拉取指定镜像或者库镜像;
1 [root@docker ~]# docker pull redis 2 Using default tag: latest 3 latest: Pulling from library/redis 4 1ab2bdfe9778: Already exists 5 966bc436cc8b: Pull complete 6 c1b01f4f76d9: Pull complete 7 8a9a85c968a2: Pull complete 8 8e4f9890211f: Pull complete 9 93e8c2071125: Pull complete 10 Digest: sha256:9755880356c4ced4ff7745bafe620f0b63dd17747caedba72504ef7bac882089 11 Status: Downloaded newer image for redis:latest 12 docker.io/library/redis:latest 13
docker push 推送指定镜像或者库镜像至docker源服务器;
1 暂无演示 2
docker history 展示一个镜像形成历史;
1 [root@docker ~]# docker history nginx 2 IMAGE CREATED CREATED BY SIZE COMMENT 3 5a3221f0137b 9 days ago /bin/sh -c #(nop) CMD ["nginx" "-g" "daemon… 0B 4 <missing> 9 days ago /bin/sh -c #(nop) STOPSIGNAL SIGTERM 0B 5 <missing> 9 days ago /bin/sh -c #(nop) EXPOSE 80 0B 6 <missing> 9 days ago /bin/sh -c ln -sf /dev/stdout /var/log/nginx… 22B 7 <missing> 9 days ago /bin/sh -c set -x && addgroup --system -… 56.8MB 8 <missing> 9 days ago /bin/sh -c #(nop) ENV PKG_RELEASE=1~buster 0B 9 <missing> 9 days ago /bin/sh -c #(nop) ENV NJS_VERSION=0.3.5 0B 10 <missing> 9 days ago /bin/sh -c #(nop) ENV NGINX_VERSION=1.17.3 0B 11 <missing> 11 days ago /bin/sh -c #(nop) LABEL maintainer=NGINX Do… 0B 12 <missing> 11 days ago /bin/sh -c #(nop) CMD ["bash"] 0B 13 <missing> 11 days ago /bin/sh -c #(nop) ADD file:330bfb91168adb4a9… 69.2MB
docker images 列出系统当前镜像;
1 [root@docker ~]# docker images 2 REPOSITORY TAG IMAGE ID CREATED SIZE 3 zml/centos-ssh latest dcb2808921c7 3 hours ago 227MB 4 nginx v1 9b0f60cb8e35 26 hours ago 625MB 5 tomcat latest 96c4e536d0eb 3 days ago 506MB 6 nginx latest 5a3221f0137b 9 days ago 126MB 7 redis latest f7302e4ab3a8 11 days ago 98.2MB 8 mysql latest 62a9f311b99c 11 days ago 445MB 9 jdeathe/centos-ssh latest b276984abde3 2 months ago 225MB 10
docker run 创建一个新的容器并运行一个命令;
1 [root@docker ~]# docker run -itd nginx 2 5b6017b66e6cc8b1d0a9c3a5a4290e8560cb89c428025adcd2fa294e09688d5b 3
docker start 启动容器;
[root@docker ~]# docker commit 5b6017b66e6c >nginx_v1.tar [root@docker ~]# ls anaconda-ks.cfg centos.tar docker nginx_v1.tar
docker stop 停止容器;
1 [root@docker ~]# docker stop 5b6017b66e6c 2 5b6017b66e6c
docker attach 当前shell下attach连接指定运行镜像;
docker build 通过Dockerfile定制镜像;
docker commit 提交当前容器为新的镜像;
[root@docker ~]# docker commit 5b6017b66e6c >nginx_v1.tar [root@docker ~]# ls anaconda-ks.cfg centos.tar docker nginx_v1.tar
docker cp 从容器中拷贝指定文件或者目录到宿主机中;
docker create 创建一个新的容器,同run,但不启动容器;
docker diff 查看docker容器变化;
docker events 从docker服务获取容器实时事件;
docker exec 在已存在的容器上运行命令;
docker export 导出容器的内容流作为一个tar归档文件[对应import];
docker import 从tar包中的内容创建一个新的文件系统映像[对应export];
docker info 显示系统相关信息;
docker inspect 查看容器详细信息;
docker kill 指定docker容器;
docker load 从一个tar包中加载一个镜像[对应save];
docker login 注册或者登陆一个docker源服务器;
docker logout Dockerregistry退出;
docker logs 输出当前容器日志信息;
docker port 查看映射端口对应的容器内部源端口;
docker pause 暂停容器;
docker ps 列出容器列表;
docker restart 重启运行的容器;
docker rm 移除一个或者多个容器;
docker rmi 移除一个或多个镜像;
docker save 保存一个镜像为一个tar包[对应load];
docker tag 给源中镜像打标签;
docker top 查看容器中运行的进程信息;
docker unpause 取消暂停容器;
docker version 查看docker版本号;
docker wait 截取容器停止时的退出状态值;
以上是关于docker常用命令详解的主要内容,如果未能解决你的问题,请参考以下文章
31-Docker-常用命令详解-docker commit