docker使用笔记

查看本机上所有镜像

bash 复制代码
docker images

打包项目(打包完成后自动载入镜像)

The command docker build -t search-server . you provided is a standard way to build a Docker image. The -t flag tags the resulting image, and search-server is the tag (name) you're assigning to the image. The . at the end of the command tells Docker to use the current directory for the build context, which should contain your Dockerfile.

Here are some points to ensure and improve the build process:

  1. Dockerfile Quality: Make sure your Dockerfile is properly written, following best practices such as minimizing the number of layers, ordering multi-line arguments, and removing unnecessary files.

  2. Build Context: Only include necessary files in your build context directory to avoid sending a large context to the Docker daemon. You can use a .dockerignore file to exclude files and directories.

  3. Build Cache: Docker uses a build cache to speed up image creation. If you need to avoid using the cache, use the --no-cache flag.

  4. Multi-Stage Builds: If you have a complex build process, consider using multi-stage builds to keep your final image size small.

  5. Security: Remove any sensitive data from the Dockerfile and avoid using plain text credentials. Use secrets or environment variables where necessary.

  6. Image Size: Use slim or alpine versions of base images where possible to keep your image size small.

  7. Error Handling: Ensure that you have proper error handling and verification steps in your Dockerfile commands.

If the image builds successfully without errors and works as expected, then your build command and Dockerfile are likely fine. However, if you are encountering issues or need specific improvements, you may need to adjust your Dockerfile or build command accordingly.

bash 复制代码
docker build -t search-server .

导出docker的时候如何加TAG

增加TAG(这一步好像不需要)

bash 复制代码
docker tag 363fcdaf92c3 search-server:latest

导出镜像

bash 复制代码
docker save image-id > search-server.tar

bash 复制代码
docker save search-server:latest > search-server.tar

载入镜像

bash 复制代码
docker load < search-server.tar

运行镜像

bash 复制代码
docker run -p 4100:4100 search-server

卸载镜像

bash 复制代码
docker rm c75f653c4b23

删除镜像

bash 复制代码
docker rmi 363fcdaf92c3
相关推荐
梦想的颜色13 小时前
【Docker部署插件】:使用 Docker 部署生产级 Kafka 完整版教程
安全·docker·中间件·kafka·消息队列·docker-compose·后端开发
↘"LYong13 小时前
旧版 CentOS 安装 Docker 完整指南(附国内镜像加速)
linux·运维·docker
满意的星月15 小时前
基于微服务和Docker容器技术的PaaS云平台架构设计(微服务架构实施原理)
docker·微服务·架构
sukioe17 小时前
【无标题】
后端·docker·centos
HAPPY酷19 小时前
【ROS2】VMware + Docker 运行 Gazebo 崩溃与“假死”排查实录
qt·docker·容器
想你依然心痛1 天前
嵌入式容器:Docker与BalenaOS在边缘设备上的实践——容器运行时与OTA
运维·docker·容器
不瘦80斤不改名1 天前
HalfCart:基于LBS的1\.5km本地拼单系统全栈实践与踩坑复盘
python·docker·typescript·pycharm
Tronlong创龙1 天前
SBC-TL3588 单板机 / EPC-TL3588 工控机 Docker 开发手册(二)
docker·开发板·嵌入式开发·硬件开发·工业控制
AI服务老曹2 天前
视觉算法模型管理完整流程:多版本上线、灰度发布与回滚的落地实践
人工智能·docker·音视频
辉的技术笔记2 天前
拆解 Dify 的 Celery:15 个队列都在干什么
docker