Docker常用命令
本次测试的docker版本是Docker version 18.09.0, build 4d60db4在以前的版本中,具体哪一个我没有仔细研究,docker的配置路径如下:环境配置文件/etc/sysconfig/docker-network/etc/sysconfig/docker-storage/etc/sysconfig/dockerunit file/usr/lib/sy...
·
本次测试的docker版本是Docker version 18.09.0, build 4d60db4
在以前的版本中,具体哪一个我没有仔细研究,docker的配置路径如下:
- 环境配置文件
/etc/sysconfig/docker-network
/etc/sysconfig/docker-storage
/etc/sysconfig/docker - unit file
/usr/lib/systemd/system/docker.service - docker registry
/etc/containers/registries.conf
docker-ce的配置文件路径(本次测试):
/etc/docker/daemon.json
这个文件在最开始的时候没有,需要我们自己创建,后面我应该会专门去学习一下daemon.json这个文件中的可配置项。到时候再把总结分享出来
这次我修改daemon.json,定义一个镜像加速器,国内有很多镜像加速的服务公司,docker-cn, 网易,阿里云,中国科技大学等等。这个配置我之前在之前的文章Centos7自定义docker engine 安装源有提过。
/etc/docker/daemon.json
{
"registry-mirrors":["https://registry.docker-cn.com"]
}
docker 命令:
- docker --help 最强的命令,没有之一
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default
"/root/.docker")
-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:
builder Manage builds
config Manage Docker configs
container Manage containers
engine Manage the docker engine
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
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
deploy Deploy a new stack or update an existing stack
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
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes
Run 'docker COMMAND --help' for more information on a command.
在新版本的docker中,docker提供了命令分组
docker version:
Client:
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:48:22 2018
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:19:08 2018
OS/Arch: linux/amd64
Experimental: false
docker info:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 18.09.0
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: c4446665cb9c30056f4998ed953e6d4ff22c7c39
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-957.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 991.2MiB
Name: localhost.localdomain
ID: LJZB:MTK4:EQRF:IEWE:NBIJ:T27L:3BIC:DQBY:IQEF:PW3F:BQ2R:MW6O
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://registry.docker-cn.com/
Live Restore Enabled: false
Product License: Community Engine
image
- docker image pull xxx:tag 下载指定的镜像
- docker image ls 列出本地所有镜像文件
- docker image rm 删除指定的镜像
container
- docker container ls = docker ps 显示所有容器
- docker container run 启动一个容器,要注意容器启动时候的启动参数
栗子: docker container run --name nginx1 -d nginx:1.14-alpine - docker inspect nginx1 获取nginx1运行时的信息
- docker create 创建一个新的容器
- docker exec
- docker attach 连接到某个容器
- docker logs 获取container的日志
- docker restart 重起容器
- docker stop 停止容器
- docker kill 杀掉一个容器
- docker rm 删除一个容器
docker 状态
更多推荐
已为社区贡献2条内容
所有评论(0)