docker-solr 使用host模式修改默认的8983端口号

时间:2021-02-01 11:09:16

1、使用root账号进入docker-solr

docker exec -it 127627ab6247 -u root /bin/bash

2、安装vim

  apt-get update

  apt-get install vim

3、修改配置文件

  docker exec -it 127627ab6247 /bin/bash

  cd /opt/solr/bin

  vim solr.in.sh

  将:

# Sets the port Solr binds to, default is 8983
SOLR_PORT=8983
改为
SOLR_PORT=$SOLR_PORT 或则其它端口号

  其中:SOLR_PORT通过docker-compose.yml用environment设置:

  solr-1:
image: solr:6.4.1
ports:
- "8981"
network_mode: "host"
container_name: solr-1
restart: always
environment:
ZK_HOST: devserver:2171,devserver:2181,devserver:2191
SOLR_PORT: 8981

  

4、在宿主机提交容器solr1为新的镜像,命名为centos-self-solr

 docker commit solr-1 solrcloud-1
docker commit solr-2 solrcloud-2
docker commit solr-3 solrcloud-3