docker+elastic search使用笔记

这篇博客详细介绍了如何使用Docker运行Elasticsearch,包括构建、导出和加载镜像,设置IK插件,数据挂载以及容器管理。重点讲解了Docker命令如`docker build`、`docker run`以及如何自定义Dockerfile来优化Elasticsearch的配置。
摘要由CSDN通过智能技术生成

查看本机上所有镜像

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.

docker build -t search-server .

带缓存构建(可能由于代理的问题,这条命令大概率会失败):

docker buildx build --push --tag search-server:latest --cache-from=type=registry,ref=search-server:latest --cache-to=type=inline .

导出docker后增加TAG(这一步好像不需要)

docker tag 363fcdaf92c3 search-server:latest

导出镜像

windows环境用这种方法导出很可能会造成linux下无法加载:

docker save image-id > search-server.tar

docker save search-server:latest > search-server.tar

采用以下方式

  • 8
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AlphaFinance

您的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值