Docker常用命令

1.帮助命令

docker version         显示版本信息

docker info               显示docker的系统信息,包括镜像和容器个数

docker 命令 --help    帮助命令

帮助文档

2.镜像命令

2.1 docker images 查看本地的主机上的所有镜像

[root@bogon ~]# docker images --help

Usage:  docker images [OPTIONS] [REPOSITORY[:TAG]]

List images

Aliases:
  docker image ls, docker image list, docker images

Options:
  -a, --all             Show all images (default hides intermediate images)
      --digests         Show digests
  -f, --filter filter   Filter output based on conditions provided
      --format string   Format output using a custom template:
                        'table':            Print output in table format with column headers
                        (default)
                        'table TEMPLATE':   Print output in table format using the given Go
                        template
                        'json':             Print in JSON format
                        'TEMPLATE':         Print output using the given Go template.
                        Refer to https://docs.docker.com/go/formatting/ for more information
                        about formatting output with templates
      --no-trunc        Don't truncate output
  -q, --quiet           Only show image IDs

[root@bogon ~]# docker images 
REPOSITORY      TAG            IMAGE ID       CREATED         SIZE
nginx           latest         605c77e624dd   22 months ago   141MB
redis           latest         7614ae9453d1   22 months ago   113MB
rabbitmq        3-management   6c3c2a225947   22 months ago   253MB
hello-world     latest         feb5d9fea6a5   2 years ago     13.3kB
kibana          7.12.1         cf1c9961eeb6   2 years ago     1.06GB
elasticsearch   7.12.1         41dc8ea0f139   2 years ago     851MB
mysql           5.7.25         98455b9624a9   4 years ago     372MB
REPOSITORY        镜像的仓库源

TAG                        镜像的标签

IMAGE ID               镜像的id

CREATED ID          镜像的创建时间

SIZE                        镜像的大小

可选项

-a, --all          列出所有镜像

-q, --quit        只显示镜像的id

[root@bogon ~]# docker images -a
REPOSITORY      TAG            IMAGE ID       CREATED         SIZE
nginx           latest         605c77e624dd   22 months ago   141MB
redis           latest         7614ae9453d1   22 months ago   113MB
 

[root@bogon ~]# docker images -q
605c77e624dd
7614ae9453d1


2.2 docker search 搜索镜像

[root@bogon ~]# docker search --help

Usage:  docker search [OPTIONS] TERM

Search Docker Hub for images

Options:
  -f, --filter filter   Filter output based on conditions provided
      --format string   Pretty-print search using a Go template
      --limit int       Max number of search results
      --no-trunc        Don't truncate output
 

[root@bogon ~]# docker search mysql
NAME                            DESCRIPTION                                      STARS     OFFICIAL 
  AUTOMATED
mysql                           MySQL is a widely used, open-source relation…   14535     [OK]      
 
mariadb                         MariaDB Server is a high performing open sou…   5552      [OK]      
 

可选项

--filter =STARS==3000  

[root@bogon ~]# docker search mysql --filter=STARS=3000
NAME      DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
mysql     MySQL is a widely used, open-source relation…   14535     [OK]       
mariadb   MariaDB Server is a high performing open sou…   5552      [OK]       

2.3 docker pull 下载镜像

[root@bogon ~]# docker pull --help

Usage:  docker pull [OPTIONS] NAME[:TAG|@DIGEST]

Download an image from a registry

Aliases:
  docker image pull, docker pull

Options:
  -a, --all-tags                Download all tagged images in the repository
      --disable-content-trust   Skip image verification (default true)
      --platform string         Set platform if server is multi-platform capable
  -q, --quiet                   Suppress verbose output
 

[root@bogon ~]# docker pull mysql     
Using default tag: latest                  如果不写tag 默认latest
latest: Pulling from library/mysql     分层下载 联合文件系统
72a69066d2fe: Pull complete 
93619dbc5b36: Pull complete 
99da31dd6142: Pull complete 
626033c43d70: Pull complete 
37d5d7efb64e: Pull complete 
ac563158d721: Pull complete 
d2ba16033dad: Pull complete 
688ba7d5c01a: Pull complete 
00e060b6d11d: Pull complete 
1c04857f594f: Pull complete 
4d7cfa90e6ea: Pull complete 
e0431212d27d: Pull complete 
Digest: sha256:e9027fe4d91c0153429607251656806cc784e914937271037f7738bd5b8e7709
Status: Downloaded newer image for mysql:latest  真实地址
docker.io/library/mysql:latest
 

指定版本下载 

[root@bogon ~]# docker pull mysql:5.7
5.7: Pulling from library/mysql
72a69066d2fe: Already exists 
93619dbc5b36: Already exists 
99da31dd6142: Already exists 
626033c43d70: Already exists 
37d5d7efb64e: Already exists 
ac563158d721: Already exists 
d2ba16033dad: Already exists 
0ceb82207cd7: Pull complete 
37f2405cae96: Pull complete 
e2482e017e53: Pull complete 
70deed891d42: Pull complete 
Digest: sha256:f2ad209efe9c67104167fc609cca6973c8422939491c9345270175a300419f94
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
 

2.4 dokcer rmi 删除镜像

docker rmi -f 镜像id                         删除指定镜像

                  

docker rmi -f 镜像id 镜像id  镜像id  删除多个镜像

 docker rmi -f $(docker images -aq) 删除全部镜像

[root@bogon ~]# docker rmi -f c20987f18b13
Untagged: mysql:5.7
Untagged: mysql@sha256:f2ad209efe9c67104167fc609cca6973c8422939491c9345270175a300419f94
Deleted: sha256:c20987f18b130f9d144c9828df630417e2a9523148930dc3963e9d0dab302a76
Deleted: sha256:6567396b065ee734fb2dbb80c8923324a778426dfd01969f091f1ab2d52c7989
Deleted: sha256:0910f12649d514b471f1583a16f672ab67e3d29d9833a15dc2df50dd5536e40f
Deleted: sha256:6682af2fb40555c448b84711c7302d0f86fc716bbe9c7dc7dbd739ef9d757150
Deleted: sha256:5c062c3ac20f576d24454e74781511a5f96739f289edaadf2de934d06e910b92

3.容器命令

有了镜像才可以创建容器(下载centos)

[root@bogon ~]# docker pull centos

3.1 docker run 启动容器

docker run [可选参数] image

参数说明

--name="Name"                 容器名字        

-d                                        后台方式运行

-it                                        交互方式,进入容器查看内容

-P                                       指定容器端口 -p  8080:8080

      -P       ip:主机端口:容器端口

      -P       主机端口:容器端口

      -P       容器端口

 容器端口

-p                                        随机指定端口

启动并进入容器

[root@bogon ~]# docker run -it centos /bin/bash
[root@d20638f688cc /]# ls
bin  etc   lib    lost+found  mnt  proc  run   srv  tmp  var
dev  home  lib64  media       opt  root  sbin  sys  usr

[root@d20638f688cc /]# exit   从容器退出
exit

3.2 docker ps 查看运行的容器

-a 列出正在运行的容器,历史运行过的容器

-n=? 显示最近创建的容器

-q    只显示容器的编号

[root@bogon ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

[root@bogon ~]# docker ps -a -n=1
CONTAINER ID   IMAGE    COMMAND     CREATED     STATUS    PORTS     NAMES
d20638f688cc      centos    "/bin/bash"   6 minutes ago   Exited (0) 4 minutes ago             condescending_bohr
 

3.3 退出容器

exit           容器停止并退出

Ctrl+P+Q  容器不停止退出

3.4 docker rm 删除容器

docker rm 容器id                      (不能删除正在运行的容器)

docker rm  -f  $(docker ps -aq)   删除所有的容器(强制删除在运行的容器)

docker ps -a -q|xargs docker rm 删除所有的容器

3.5 启动和停止容器

docker start 容器id       启动容器

docker restart 容器id    重启容器

docker stop 容器id       停止在运行的容器

docker kill  容器id         强制停止

[root@bogon ~]# docker start fc84b8115818
fc84b8115818
[root@bogon ~]# docker ps
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS          PORTS     NAMES
fc84b8115818   centos    "/bin/bash"   49 seconds ago   Up 15 seconds             nifty_lamarr
[root@bogon ~]# docker stop  fc84b8115818
fc84b8115818
[root@bogon ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

4. 其他常用命令

后台启动容器

[root@bogon ~]# docker run -d centos
20ed80fc5ead0830d44ecac0a6e7beda42a8f0648443d42192bb8692a374de41

ps时发现centos停止(docker容器运行时,必须要有前台进程,docker发现没有应用就会自动停止)

查看日志

docker logs  -tf --tail number 容器

查看容器中的进程信息

docker top 容器id

查看容器信息

docker inspect 容器id

进入正在运行的容器

docker exec -it 容器id (进入容器后开启新的终端)

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

从容器拷贝文件

docker cp 容器id:容器内路径  目的地主机路径
 

视频地址 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
智慧校园建设方案旨在通过融合先进技术,如物联网、大数据、人工智能等,实现校园的智能化管理与服务。政策的推动和技术的成熟为智慧校园的发展提供了基础。该方案强调了数据的重要性,提出通过数据的整合、开放和共享,构建产学研资用联动的服务体系,以促进校园的精细化治理。 智慧校园的核心建设任务包括数据标准体系和应用标准体系的建设,以及信息化安全与等级保护的实施。方案提出了一站式服务大厅和移动校园的概念,通过整合校内外资源,实现资源共享平台和产教融合就业平台的建设。此外,校园大脑的构建是实现智慧校园的关键,它涉及到数据中心化、数据资产化和数据业务化,以数据驱动业务自动化和智能化。 技术应用方面,方案提出了物联网平台、5G网络、人工智能平台等新技术的融合应用,以打造多场景融合的智慧校园大脑。这包括智慧教室、智慧实验室、智慧图书馆、智慧党建等多领域的智能化应用,旨在提升教学、科研、管理和服务的效率和质量。 在实施层面,智慧校园建设需要统筹规划和分步实施,确保项目的可行性和有效性。方案提出了主题梳理、场景梳理和数据梳理的方法,以及现有技术支持和项目分级的考虑,以指导智慧校园的建设。 最后,智慧校园建设的成功依赖于开放、协同和融合的组织建设。通过战略咨询、分步实施、生态建设和短板补充,可以构建符合学校特色的生态链,实现智慧校园的长远发展。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值