赞
踩
本文看下如何自定义镜像。
ik包从这里 下载。
先看下目录结构:
/opt/program/mychinese
[root@localhost mychinese]# ll
total 16
-rw-r--r-- 1 root root 1153 Feb 5 04:18 docker-compose.yaml
-rw-rw-r-- 1 elk elk 291 Feb 5 04:17 Dockerfile
drwxr-xr-x 3 root root 243 Feb 5 03:27 ik710
ik710
目录就是ik的解压内容,后续回安装到es,直接拷贝到es的plugins目录就行。
Dockerfile内容:
FROM docker.elastic.co/elasticsearch/elasticsearch:7.1.0
RUN mkdir /usr/share/elasticsearch/plugins/ik710
#RUN cd /usr/share/elasticsearch/plugins/ik710
ADD ik710 /usr/share/elasticsearch/plugins/ik710
# CMD echo "es will start!!!"
# CMD ["/usr/share/elasticsearch/bin/elasticsearch", "-d"]
接着就可以构建镜像了:
docker build -t mychinese:1.2 .
[root@localhost mychinese]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mychinese 1.2 d0aec608ff4f 12 minutes ago 904 MB
...
接着就可以使用docker-compose 启动了,内容如下:
version: '2.2' services: elasticsearch: image: mychinese:1.2 container_name: es7_011 environment: - cluster.name=geektime - node.name=es7_011 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - discovery.seed_hosts=es7_011,es7_012 - cluster.initial_master_nodes=es7_011,es7_012 ulimits: memlock: soft: -1 hard: -1 volumes: - es7data1:/usr/share/elasticsearch/data ports: - 9220:9200 networks: - es7net elasticsearch2: image: mychinese:1.2 container_name: es7_012 environment: - cluster.name=geektime - node.name=es7_012 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - discovery.seed_hosts=es7_011,es7_012 - cluster.initial_master_nodes=es7_011,es7_012 ulimits: memlock: soft: -1 hard: -1 volumes: - es7data2:/usr/share/elasticsearch/data networks: - es7net volumes: es7data1: driver: local es7data2: driver: local networks: es7net: driver: bridge
启动:
[root@localhost mychinese]# docker-compose up
Creating es7_011 ... done
Creating es7_012 ... done
Attaching to es7_012, es7_011
es7_011 | {"type": "server", "timestamp": "2024-02-05T09:32:29,486+0000", "level": "INFO", "component": "o.e.p.PluginsService", "cluster.name": "geektime", "node.name": "es7_011", "message": "loaded plugin [analysis-ik]" } # 这里可以看到加载analysis-ik插件了
...
查看:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。