docker其它命令-阿里云开发者社区

开发者社区> 开发与运维> 正文
登录阅读全文

docker其它命令

简介: Docker 是一种运行于 Linux 和 Windows 上的软件,用于创建、管理和编排容器。Docker 是一种运行于 Linux 和 Windows 上的软件,用于创建、管理和编排容器。Docker 镜像理解为 VM 模板,VM 模板就像停止运行的 VM,而 Docker 镜像就像停止运行的容器;而作为一名研发人员,则可以将镜像理解为类(Class),我们在使用docker过程中,经常和镜像、容器打交道,今天主要介绍下查看元数据,进程,进入容器和拷贝等命令

1.查看容器内进程信息

docker top 容器ID

image.png

2.查看容器元数据信息,元数据信息是JSON格式的字符串,包含有很多内容,容器的ID、创建时间、状态、数据卷等等。

docker inspect 容器ID

image.png3. 进入当前正在运行的容器

通常运行容器是以后台方式运行的,使用以下命令进入正在运行的容器

docker exec -it 容器 /bin/bash 进入容器后开启一个新的终端,可以在里面操作

image.png

docker attach 容器 进入容器正在执行的终端,不会启动新的进程。

  1. 把容器内文件拷贝到主机

docker cp 容器:容器内路径 主机路径

image.png

5.小节

image.png

此图包含有镜像的命令,容器命令,帮助信息等等,以下是官方列举的基本命令及描述信息

docker attachAttach local standard input, output, and error streams to a running container
docker buildBuild an image from a Dockerfile
docker builderManage builds
docker checkpointManage checkpoints
docker commitCreate a new image from a container’s changes
docker configManage Docker configs
docker containerManage containers
docker contextManage contexts
docker cpCopy files/folders between a container and the local filesystem
docker createCreate a new container
docker diffInspect changes to files or directories on a container’s filesystem
docker eventsGet real time events from the server
docker execRun a command in a running container
docker exportExport a container’s filesystem as a tar archive
docker historyShow the history of an image
docker imageManage images
docker imagesList images
docker importImport the contents from a tarball to create a filesystem image
docker infoDisplay system-wide information
docker inspectReturn low-level information on Docker objects
docker killKill one or more running containers
docker loadLoad an image from a tar archive or STDIN
docker loginLog in to a Docker registry
docker logoutLog out from a Docker registry
docker logsFetch the logs of a container
docker manifestManage Docker image manifests and manifest lists
docker networkManage networks
docker nodeManage Swarm nodes
docker pausePause all processes within one or more containers
docker pluginManage plugins
docker portList port mappings or a specific mapping for the container
docker psList containers
docker pullPull an image or a repository from a registry
docker pushPush an image or a repository to a registry
docker renameRename a container
docker restartRestart one or more containers
docker rmRemove one or more containers
docker rmiRemove one or more images
docker runRun a command in a new container
docker saveSave one or more images to a tar archive (streamed to STDOUT by default)
docker searchSearch the Docker Hub for images
docker secretManage Docker secrets
docker serviceManage services
docker stackManage Docker stacks
docker startStart one or more stopped containers
docker statsDisplay a live stream of container(s) resource usage statistics
docker stopStop one or more running containers
docker swarmManage Swarm
docker systemManage Docker
docker tagCreate a tag TARGET_IMAGE that refers to SOURCE_IMAGE
docker topDisplay the running processes of a container
docker trustManage trust on Docker images
docker unpauseUnpause all processes within one or more containers
docker updateUpdate configuration of one or more containers
docker versionShow the Docker version information
docker volumeManage volumes
docker waitBlock until one or more containers stop, then print their exit codes

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

其他文章
最新文章
相关文章