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
相关推荐
尘土哥7 小时前
Docker 快速上手
docker·容器·eureka
广州山泉婚姻8 小时前
Docker从环境配置到应用上云的极简路径
docker
胡耀超13 小时前
Umi-OCR 的 Docker安装(win制作镜像,Linux(Ubuntu Server 22.04)离线部署)
linux·深度学习·ubuntu·docker·容器·nlp·ocr
铃木隼.16 小时前
docker容器高级管理-dockerfile创建镜像
运维·docker·容器
开开心心就好19 小时前
AI抠图软件,本地运行超快速
网络·人工智能·网络协议·tcp/ip·docker·电脑·excel
IT成长日记1 天前
【Docker基础】Dockerfile指令速览:文件与目录操作指令详解
docker·容器·volume·add·dockerfile·workdir
胡耀超1 天前
GraphRAG Docker化部署,接入本地Ollama完整技术指南:从零基础到生产部署的系统性知识体系
运维·docker·容器·大模型·知识图谱·rag·ollama
小趴菜吖1 天前
更换docker工作目录
docker
果子⌂1 天前
Docker高级管理
开发语言·docker·云计算·php
x县豆瓣酱1 天前
【第五节】部署http接口到ubuntu server上的docker内
ubuntu·http·docker