docker常用命令整理


基本命令 General Commands

- docker -d - start the docker daemon
- docker - help - help
- docker info - display system-wide infromation

Docker Hub 相关

- docker login -u [user-name] - Loging into docker
- docker push [user-name]/[image-name] - Publish an image to docker hub
- docker search [image-name] - Search hub for an image
- docker pull [image-name] - Pull an image from a docker hub
- docker create [image] = create a container without running
- docker create -it [image] - Create an interactive container
- docker logout - Log out of a Docker registry
- docker system prune - Remove unused images, containers, and networks

镜像操作Images

- docker build [dockerfile-path] - Create an image form a dckerfile
- docker build -t image_name] . - Build an Image from a Dockerfile
- docker build -t [image_name] . –no-cache - Build an Image from a Dockerfile without the cache
- docker images - List local images
- docker history [image] - show history for an image
- docker import [url/file] - create an image form a tarball
- docker commit [container] [new-image] - create an image from a container
- docker tag [image] [image]:[tag] - Tag an image
- docker load - name [tar-file] - Load an image from a tar archive 
- docker save [image] > [tar-file] - Save an image to a tar archive file
- docker rmi [image_name] - Delete an Image
- docker image prune - Remove all unused images
- docker run -itd - network=mynet nginx - run docker image with network

管理容器Containers

- docker run - name [container_name][image_name] - Create and run a container from an image, with a custom name
- docker run -p [host_port]:[container_port] [image_name] - Create and run a container from an image, with a custom name
- docker run -d [image_name] - Run a container in the background(detached mode)
- docker run -it [image] - Start an interactive process, such as a shell, in a container
- docker run - rm [image] - Run a container and remove it after it stops
- docker start|stop [container_name] (or [container-id]) - Start or stop an existing container
- docker restart [container] - Stop a running container and start it up again
- docker pause [container] - Pause processes in a running container
- docker unpause [container] - Resume processes in a running container
- docker wait [container] - Block a container until others stop (after which it prints their exit codes)
- docker kill [container] - Kill a container by sending a SIGKILL to a running container
- docker attach [container] - Attach local standard input, output, and error streams to a running container
- docker rm [container_name] - Remove a stopped container
- docker rm -f [container-id] - forcefully remove a container, even if it is running
- docker exec -it [container_name] sh - Open a shell inside a running container
- docker logs -f [container_name] - Fetch and follow the logs of a container
- docker inspect [container_name] (or [container_id]) - To inspect a running container
- docker ps - To list currently running containers
- docker ps - all - List all docker containers (running and stopped)
- docker container stats - View resource usage stats
- docker rename [container] [new-name] - renaming an existing container
- docker logs [container] - View logs for a running container
- docker events [container] - View real-time events for a container
- docker update [container] - Update the configuration of one or more containers
- docker port [container] - View port mapping for a container
- docker top [container] - Show running processes in a container
- docker stats [container] - View live resource usage statistics for a container
- docker diff [container] - Show changes to files or directories on the filesystem
- docker cp [file-path] [container-id]:[path] - Copy a local file to a directory in a container
- docker cp [container-id]:[path] [host-path] - Copy file from container to the local

容器网络Networks

- docker info - list network driver plugins
- docker network create -d bridge mynet - Create bridge network
- docker network create -d overlay mynet - Create overlay network
- docker network ls - List available networks
- docker network rm [network] - Remove one or more networks
- docker netwrok inspect [network] - Show information on one or more networks
- docker network connect [network] [container] - Connect a container to a network
- docker network disconnect [network] [container] - Disconnect a container from a network
- docker network prune - Remove all the unused docker networks

挂载相关Volumes

- docker volume create [name] - Create docker volumes
- docker run -itd - volume=[name]:/world nginx - creating a new docker container to attach the docker volume.
- docker volume inspect [name] - Show information about volume
- docker volume rm [name] - remove docker volumes

插件管理Plugin Management

- docker plugin enable [plugin] - Enable a Docker plugin
- docker plugin disable [plugin] - Disable a Docker plugin
- docker plugin inspect [plugin] - View details about a plugin
- docker plugin rm [plugin] - Remove a plugin

安全Security

- docker scan [image] - scan docker image
- docker scan - json [image] - display the scan result as a JSON output
展开阅读全文

页面更新:2024-03-02

标签:容器   插件   命令   操作   常用命令   网络

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top