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
相关推荐
lambo mercy11 小时前
01初识docker
运维·docker·容器
时间的拾荒人12 小时前
Docker 容器、仓库与数据管理实战
docker·容器·eureka
时间的拾荒人14 小时前
Docker 入门实战:从核心概念、安装配置到镜像操作与 Dockerfile 定制
运维·docker·容器·eureka
时间的拾荒人15 小时前
Docker Compose 编排实战:从命令详解到 Redis Cluster 三主三从部署
docker·部署·集群
AI开源软件1 天前
Kubernetes 网络实战:打通 Pod、Service 与集群外任务调度器的双向调用
docker·nacos·kubernetes·xxl-job·calico·微服务部署·ruoyi office
csdn_aspnet2 天前
Docker 啟動MySQL Server連上MySQL Workbench
mysql·docker·容器
月夏2 天前
我把全栈项目塞进已有 nginx 的服务器,卡我最久的是三个斜杠
nginx·react.js·docker
瑞克-桑切斯2 天前
Kubernetes 1.28 保姆级新手学习教程
运维·学习·docker·云原生·容器·kubernetes
对象存储与RustFS3 天前
对象锁遇上版本化:删掉的对象还在,真删的又删不掉
后端·docker·云原生
遇雪长安3 天前
wslc 来了:Docker Desktop 还要留着吗?
运维·docker·容器