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
相关推荐
java_logo2 小时前
Docker 部署 ClickHouse Server:轻松搭建列式 OLAP 分析数据库平台
数据库·clickhouse·docker·私有化部署·olap·列式数据库·轩辕镜像
冰块的旅行2 小时前
完整的 Docker + Docker Compose 部署教程亲测有效
docker·容器
乌恩大侠2 小时前
【Sionna】docker build ubuntu cuda
ubuntu·docker·容器·spark·o-ru·ai-ran
FungLeo3 小时前
成为全栈·Node 后端篇·容器化:给 Node 应用写一个像样的 Dockerfile
docker·node.js·dockerfile·成为全栈·后端服务容器·docker 容器
梅梅绵绵冰4 小时前
Docker容器化平台
docker·容器·eureka
我是唐青枫4 小时前
Docker diff 详解:看清容器里到底改了什么
docker·容器
jiao糖瓜子6 小时前
Docker 完全指南:从镜像容器到生产部署
docker·容器·eureka·镜像·仓库
JavaPub-rodert7 小时前
Docker 容器启动了,不代表服务真的能用:Healthcheck 实战
运维·docker·容器
先吃饱再说8 小时前
别再手动敲三遍 docker run 了:学会使用 Docker Compose 多容器编排
docker·容器
xixiaoyunya9 小时前
Docker 容器化部署实战:从零搭建一套完整的 Nginx + Node.js + MySQL + Redis 项目环境
nginx·docker·node.js