💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 一、概述 安装完Docker引擎之后,就可以对镜像进行基本的操作了; ## 二、镜像操作 ### **搜索镜像** ``` docker search [OPTIONS] TERM ``` ``` docker search [包名] --filter "is-official=true" ``` >[info] docker search作用有限(比如不包含包的可用tag),不如到官方网站查(http://hub.docker.com),上面有最详细的信息。得出结论后再pull到本地使用; > ![](https://img.kancloud.cn/78/0e/780e0bee3626b6072e8c6fb29ab499da_1920x942.png) ### **获取镜像** ``` docker pull [OPTIONS] NAME[:TAG|@DIGEST] ``` 例如: ``` docker pull tomcat:9.0.62-jdk17-temurin-focal ``` ### **查看镜像** ``` docker images [OPTIONS] [REPOSITORY[:TAG]] ``` 例如: ``` docker images tomcat ``` ### **删除镜像** ``` docker rmi [OPTIONS] IMAGE [IMAGE...] ``` 例如: ``` docker rmi tomcat:9.0.62-jdk17-temurin-focal docker rmi dea4988b357f ``` ## 三、实战 ### **下载镜像** ``` docker search centos ``` ![](https://img.kancloud.cn/1b/87/1b876fcdfcb0cf1135b6f04fc8410281_1051x405.png) ``` docker pull centos ``` ![](https://img.kancloud.cn/8a/f6/8af6a1d201f430eb3ce805d47743db36_1043x101.png) ``` docker images ``` ![](https://img.kancloud.cn/c3/79/c379b5fa51006c6060c38521573314cb_1051x46.png) ### **启动容器** 启动一个容器; ``` docker run -it centos:latest /bin/bash ``` ![](https://img.kancloud.cn/5c/7e/5c7e3bb9e1c8305052bb7c325b8a26c9_1043x34.png) ### **容器里部署软件** 接下来就可以在容器里面,安装各种软件,甚至部署各种应用,跟一个独立的linux一样操作; ### **退出容器** ``` exit ``` ![](https://img.kancloud.cn/46/f3/46f31477c38e65fd42ef91cf34102401_1048x51.png) 退出后,容器仍然在运行,只是退出到物理机环境,可以进行容器镜像的制作了; ### **制作新镜像** ``` docker commit -m "centos with raydev" -a "rayframework" e13eaa0056aa rayframework/centoswithraydev:v1 ``` > 命令中,e13eaa0056aa 为当前容器的id; ![](https://img.kancloud.cn/cc/9f/cc9fe9e09b04320483e0058500dceba6_979x39.png) ``` docker images ``` ![](https://img.kancloud.cn/83/24/832464969bb782ee4586e6bc93879166_1052x49.png) >[danger] > 1、这里通commit可以将容器转化为一个镜像,执行commit操作,完成后可使用docker images查看; > 2、72f1a8a0e394 为当前的容器Id,docker ps -a命令可以查看到; ### **使用新镜像容器** ``` docker run -it ${REPOSITORY}:${TAG} /bin/bash ``` ![](https://img.kancloud.cn/64/bc/64bc396e5aad96161388b6411cda8f39_999x37.png)