赞
踩
rm -f $(docker ps -aq) 删除所有docker容器
docker ps -aq|xargs docker rm -f 也可以删除所有的容器
当使用docker stop 无法停止时,可以使用docker kill 直接杀掉
现在搭建部署环境基本都是用Docker进行,学会Docker指令相当重要。在我的Docker系列文章中我们已经进行了很多准备工作,我是在云服务器上面进行部署的工作,大大省去了虚拟机环境配置时间,大家可以用用看:
云服务器Centos8.2SSH登陆、安装部署图形化界面以及VNC连接一文详解
云服务器CentOS8.2Docker图形化管理工具Portainer安装部署
下面仍旧还是使用SecureCRT进行指令演示。
很多学Python伙伴问题有没有体系的面试题?
今天为大家推荐一款刷题神奇哦 :刷题面试神器牛客
各大互联网大厂面试真题。从基础到入阶乃至原理刨析类面试题 应有尽有,赶快来装备自己吧!助你面试稳操胜券,solo全场面试官
systemctl start docker
systemctl status docker
systemctl stop docker
systemctl enable docker
docker version
docker info
docker --help
若忘记了某个指令的功能可以在后面加上help查看功能:
docker 指令参数 --help
docker images
可以通过–help查看每一个Image命令的详细信息。
docker image ls --help
显示所有镜像(默认隐藏中间图像)
docker image ls -a
docker images
、docker image ls
和docker image ls -a
是一样的效果。
docker image ls -q
仅输出image的IMAGE ID。
docker search 镜像名
比如:
docker search [OPTIONS] TERM
其中OPTIONS有:
代码如下(示例):
docker search --filter=stars=10000 mysql
docker search --format "{{.Name}}:{{.StarCount}}" mysql
docker search --format "table {{.Name}}\t{{.IsAutomated}}\t{{.IsOfficial}}" redis
docker search redis --filter=stars=500 --limit 3
docker search --no-trunc mysql
代码如下(示例):
docker image pull
参数可以选有两个:
例如拉取一个最新的redis:
docker image pull redis
拉取完后docker images查看:
代码如下:
docker image prune [OPTIONS]
docker image rm [OPTIONS] IMAGE [IMAGE...]
删除TAG为latest最新版本的redis:
docker image rm redis:latest
docker image tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
docker image tag hello-world:latest hello-world:v.1.0
docker image save [OPTIONS] IMAGE [IMAGE...]
docker image save hello-world:v.1.0 > hw.tar
保存到指定目录:
docker image save hello-worl:v.1.0 -o /usr/local/hw.tar
docker image load [OPTIONS]
我们一开始是把hello-world的v.1.0的版本给删了,现在我们可以把通过本地保存的hello-world给放到image里面去:
docker image load <hw.tar
加载指定路径的镜像源:
docker load -i /usr/local/hw.tar # 指定加载镜像的源
docker image history [OPTIONS] IMAGE
docker image history hello-world:v.1.0
docker image inspect [OPTIONS] IMAGE [IMAGE...]
例如我们查看hello-world镜像的详细信息会发现:
docker image inspect hello-world
一大串JSON文件格式:
docker image import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
docker image import hw.tar # 一般需要指定镜像名字
docker image push [OPTIONS] NAME[:TAG]
这样就是上传成功了可以在dockerhub上看到自己上传的镜像:
docker push fanstuck/my-private-repo:hellow-world
docker image build [OPTIONS] PATH | URL | -
bulid属于制作镜像是一个较为复杂且需要编写程序的过程,因此参数相应的会比较复杂:
Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Options: --config string Location of client config files (default "/root/.docker") -c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use") -D, --debug Enable debug mode -H, --host list Daemon socket(s) to connect to -l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info") --tls Use TLS; implied by --tlsverify --tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem") --tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem") --tlskey string Path to TLS key file (default "/root/.docker/key.pem") --tlsverify Use TLS and verify the remote -v, --version Print version information and quit Management Commands: app* Docker App (Docker Inc., v0.9.1-beta3) builder Manage builds buildx* Build with BuildKit (Docker Inc., v0.6.3-docker) compose* Docker Compose (Docker Inc., v2.6.0) config Manage Docker configs container Manage containers context Manage contexts image Manage images manifest Manage Docker image manifests and manifest lists network Manage networks node Manage Swarm nodes plugin Manage plugins scan* Docker Scan (Docker Inc., v0.17.0) secret Manage Docker secrets service Manage services stack Manage Docker stacks swarm Manage Swarm system Manage Docker trust Manage trust on Docker images volume Manage volumes Commands: attach Attach local standard input, output, and error streams to a running container build Build an image from a Dockerfile commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container diff Inspect changes to files or directories on a container's filesystem events Get real time events from the server exec Run a command in a running container export Export a container's filesystem as a tar archive history Show the history of an image images List images import Import the contents from a tarball to create a filesystem image info Display system-wide information inspect Return low-level information on Docker objects kill Kill one or more running containers load Load an image from a tar archive or STDIN login Log in to a Docker registry logout Log out from a Docker registry logs Fetch the logs of a container pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container ps List containers pull Pull an image or a repository from a registry push Push an image or a repository to a registry rename Rename a container restart Restart one or more containers rm Remove one or more containers rmi Remove one or more images run Run a command in a new container save Save one or more images to a tar archive (streamed to STDOUT by default) search Search the Docker Hub for images start Start one or more stopped containers stats Display a live stream of container(s) resource usage statistics stop Stop one or more running containers ![img](https://img-blog.csdnimg.cn/img_convert/e7bba6d5de5f7496b3d86f26be7c3ccb.png) ![img](https://img-blog.csdnimg.cn/img_convert/5f2e022dd4812a0c16359f2de51350a8.png) **网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。** **[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)** **一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!** Remove one or more images run Run a command in a new container save Save one or more images to a tar archive (streamed to STDOUT by default) search Search the Docker Hub for images start Start one or more stopped containers stats Display a live stream of container(s) resource usage statistics stop Stop one or more running containers [外链图片转存中...(img-VWZOYVPB-1714149468100)] [外链图片转存中...(img-Wu4wGB0x-1714149468101)] **网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。** **[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618545628)** **一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。