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
相关推荐
一点事8 小时前
docker:安装oracle 19c
docker·oracle·容器
qq_4523962311 小时前
第四篇:《Docker 镜像:分层结构、拉取与推送》
运维·docker·容器
身如柳絮随风扬12 小时前
Docker 部署 Nginx:从入门到生产级配置实战
nginx·docker·容器
木雷坞12 小时前
dwz-server Docker 部署短链接服务:多域名、A/B 测试和统计配置
运维·docker·容器
亚空间仓鼠12 小时前
Docker容器化高可用架构部署方案(十六)
docker·容器·架构
星空13 小时前
docker
linux·运维·docker
身如柳絮随风扬13 小时前
GitLab CI 驱动禅道自动化部署:从零构建企业级 CI/CD 流水线
docker
木雷坞13 小时前
vLLM 服务上线前压测记录:镜像缓存、GPU 利用率和 p95
人工智能·机器学习·docker
AI服务老曹14 小时前
解耦异构算力与多协议接入:基于 Docker 部署的企业级 GB28181/RTSP 边缘计算 AI 视频管理平台架构解析(附源码交付)
人工智能·docker·边缘计算