docker常用操作
命令 | 功能 |
---|
docker search | 在 Docker 中心搜索映像 |
docker pull | 从注册表中拉取映像或存储库 |
docker images | 列出图像 |
docker create | 创建新的连接器 |
docker start | 启动一个或多个已停止的容器 |
docker run | 在新容器中运行命令 |
docker attach | 连接到运行容器 |
docker ps | 列出容器 |
docker logs | 获取容器的日志 |
docker restart | 重新启动容器 |
docker stop | 停止一个或多个正在运行的容器 |
docker kill | 杀死一个或多个正在运行的容器 |
docker rm | 删除容器或更多容器 |
docker exec | 在正在运行的容器中运行命令 |
docker info | 显示系统范围的信息 |
docker inspect | 返回有关 Docker 对象的低级信息 |
docker event state
![img](https://img-blog.csdnimg.cn/img_convert/f6c2abd6ee4b0572d0eebd5a9af5dbf3.jpeg)
[root@localhost ~]
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
httpd The Apache HTTP Server Project 4109 [OK]
centos/httpd-24-centos7 Platform for running Apache httpd 2.4 or bui… 44
centos/httpd 35 [OK]
clearlinux/httpd httpd HyperText Transfer Protocol (HTTP) ser… 2
hypoport/httpd-cgi httpd-cgi 2 [OK]
solsson/httpd-openidc mod_auth_openidc on official httpd image, ve… 2 [OK]
dockerpinata/httpd 1
nnasaki/httpd-ssi SSI enabled Apache 2.4 on Alpine Linux 1
lead4good/httpd-fpm httpd server which connects via fcgi proxy h… 1 [OK]
inanimate/httpd-ssl A play container with httpd, ssl enabled, an… 1 [OK]
publici/httpd httpd:latest 1 [OK]
dariko/httpd-rproxy-ldap Apache httpd reverse proxy with LDAP authent… 1 [OK]
manageiq/httpd Container with httpd, built on CentOS for Ma… 1 [OK]
centos/httpd-24-centos8 1
manasip/httpd 0
amd64/httpd The Apache HTTP Server Project 0
patrickha/httpd-err 0
manageiq/httpd_configmap_generator Httpd Configmap Generator 0 [OK]
paketobuildpacks/httpd 0
httpdss/archerysec ArcherySec repository 0 [OK]
httpdocker/kubia 0
sandeep1988/httpd-new httpd-new 0
e2eteam/httpd 0
19022021/httpd-connection_test This httpd image will test the connectivity … 0
sherazahmedvaival/httpd-php-fpm74 0
从注册表中拉取映像或存储库(也就是下载docker仓库中的镜像)
[root@localhost ~]
Using default tag: latest
latest: Pulling from library/httpd
a2abf6c4d29d: Pull complete
dcc4698797c8: Pull complete
41c22baa66ec: Pull complete
67283bbdd4a0: Pull complete
d982c879c57e: Pull complete
Digest: sha256:0954cc1af252d824860b2c5dc0a10720af2b7a3d3435581ca788dff8480c7b32
Status: Downloaded newer image for httpd:latest
docker.io/library/httpd:latest
[root@localhost ~]
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest dabbfbe0c57b 7 months ago 144MB
[root@localhost ~]
1d7553ed6b824e94b8e28f8a7b89f1f44c5c901253dbadd60866f054650860fb
//这样的方式创建会在执行完命令后退出
[root@localhost ~]
b5c6289db9e7ab4666b050be19dbdd92b95dd7defc9da91f82de71e468c41661
[root@localhost ~]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b5c6289db9e7 httpd "-it sleep 1000" 30 seconds ago Created zealous_margulis
1d7553ed6b82 httpd "httpd-foreground" About a minute ago Created focused_curran
启动一个或多个已停止的容器
[root@localhost ~]
1d7553ed6b82
[root@localhost ~]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1d7553ed6b82 httpd "httpd-foreground" 2 minutes ago Up 35 seconds 80/tcp focused_curran
进入到指定容器中执行命令
[root@localhost ~]
4a8ef91bae15991f2fe541c8b710cbd0a94da28a15b040bdf5970adfd014bb6e
[root@localhost ~]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4a8ef91bae15 httpd "httpd-foreground" 36 seconds ago Up 35 seconds 0.0.0.0:80->80/tcp, :::80->80/tcp web
1d7553ed6b82 httpd "httpd-foreground" 3 minutes ago Up About a minute 80/tcp focused_curran
获取日志信息
[root@localhost ~]
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
[Sun Aug 07 05:25:42.199748 2022] [mpm_event:notice] [pid 1:tid 140265721298240] AH00489: Apache/2.4.52 (Unix) configured -- resuming normal operations
[Sun Aug 07 05:25:42.199881 2022] [core:notice] [pid 1:tid 140265721298240] AH00094: Command line: 'httpd -D FOREGROUND'
[root@localhost ~]
1d7553ed6b82
kill杀死某个进程
[root@localhost ~]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4a8ef91bae15 httpd "httpd-foreground" 3 minutes ago Up 3 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp web
1d7553ed6b82 httpd "httpd-foreground" 6 minutes ago Up 43 seconds 80/tcp focused_curran
[root@localhost ~]
1d7553ed6b82
[root@localhost ~]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4a8ef91bae15 httpd "httpd-foreground" 3 minutes ago Up 3 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp web
删除一个或者多个容器 docker rm -f :强制删除
[root@localhost ~]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4a8ef91bae15 httpd "httpd-foreground" 4 minutes ago Up 4 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp web
b5c6289db9e7 httpd "-it sleep 1000" 7 minutes ago Created 80/tcp zealous_margulis
[root@localhost ~]
b5c6289db9e7
显示系统范围内的信息
[root@localhost ~]
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 1
Server Version: 20.10.17
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc version: v1.1.2-0-ga916309
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 4.18.0-348.el8.x86_64
Operating System: CentOS Linux 8
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 3.623GiB
Name: localhost.localdomain
ID: SUJZ:FLPL:LKKD:GR3P:SB4A:QQFL:QOJ7:FTJM:UWEM:CF2K:W4VK:7X42
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://jwzkofjg.mirror.aliyuncs.com/
Live Restore Enabled: false