Docker容器部署第二个minio服务报错,提示端口被占用了

docker环境下部署minio分布式集群,在服务器上无法部署第二个minio,如果有了解这个的,麻烦帮忙解决一下,谢谢!

  • 第一个minio的部署命令
docker run -d -p 9000:9000 -p 9090:9090 \
--name=minio-1 \
--restart=always \
-e "MINIO_ROOT_USER=minioadmin" \
-e "MINIO_ROOT_PASSWORD=minioadmin" \
-v /data/app/minio1/data1:/data1 \
-v /data/app/minio1/data2:/data2 \
-v /data/app/minio1/data3:/data3 \
-v /data/app/minio1/data4:/data4 \
-v /data/app/minio1/data5:/data5 \
-v /data/app/minio1/data6:/data6 \
-v /data/app/minio1/data7:/data7 \
-v /data/app/minio1/data8:/data8 \
-v /data/app/minio1/config:/root/.minio \
--network host \
--hostname "host1" \
minio/minio:latest server \
http://172.16.19.223:9000/data{1...8} \
http://172.16.19.223:9001/data{1...8} \
http://172.16.19.221:9000/data{1...8} \
http://172.16.19.221:9001/data{1...8} \
--console-address ":9090" 
  • 第二个minio的部署命令
docker run -d -p 9001:9001 -p 9091:9091 \
--name=minio-2 \
--restart=always \
-e "MINIO_ROOT_USER=minioadmin" \
-e "MINIO_ROOT_PASSWORD=minioadmin" \
-v /data/app/minio2/data1:/data1 \
-v /data/app/minio2/data2:/data2 \
-v /data/app/minio2/data3:/data3 \
-v /data/app/minio2/data4:/data4 \
-v /data/app/minio2/data5:/data5 \
-v /data/app/minio2/data6:/data6 \
-v /data/app/minio2/data7:/data7 \
-v /data/app/minio2/data8:/data8 \
-v /data/app/minio2/config:/root/.minio \
--network host \
--hostname "host2" \
minio/minio:latest server \
http://172.16.19.223:9000/data{1...8} \
http://172.16.19.223:9001/data{1...8} \
http://172.16.19.221:9000/data{1...8} \
http://172.16.19.221:9001/data{1...8} \
--console-address ":9091"
  • 完成部署后第一个minio服务正常的,但是第二个就报错了

[root@server223 ~]# docker logs -f minio-2
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
ERROR Unable to start the server: Specified port is already in use
      > Please ensure no other program uses the same address/port
  • 查看端口被占用情况

[root@server223 ~]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      11021/minio
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      757/rpcbind
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1495/dnsmasq
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1138/sshd
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1137/cupsd
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      16218/sshd: root@pt
tcp6       0      0 :::10912                :::*                    LISTEN      1887/java
tcp6       0      0 :::9000                 :::*                    LISTEN      11021/minio
tcp6       0      0 ::1:9000                :::*                    LISTEN      11021/minio
tcp6       0      0 :::111                  :::*                    LISTEN      757/rpcbind
tcp6       0      0 :::9876                 :::*                    LISTEN      1855/java
tcp6       0      0 :::22                   :::*                    LISTEN      1138/sshd
tcp6       0      0 ::1:631                 :::*                    LISTEN      1137/cupsd
tcp6       0      0 ::1:6010                :::*                    LISTEN      16218/sshd: root@pt
tcp6       0      0 :::10909                :::*                    LISTEN      1887/java
tcp6       0      0 :::10911                :::*                    LISTEN      1887/java

如果有了解这个的,麻烦帮忙解决一下,谢谢!

【以下回答由 GPT 生成】

由于第一个minio服务已经占用了9000和9090端口,导致第二个minio服务无法运行。解决这个问题的方法有两种:

  1. 更改第二个minio服务的端口:
    • 修改第二个minio服务的部署命令中的端口参数,将-p 9001:9001 -p 9091:9091修改为其他未被占用的端口,例如-p 9002:9000 -p 9092:9090
    • 修改第二个minio服务的部署命令,将http://172.16.19.223:9001http://172.16.19.221:9001中的端口号 9001 修改为新的端口号,例如 9002
    • 运行修改后的第二个minio容器部署命令。

shell docker run -d -p 9002:9000 -p 9092:9090 \ --name=minio-2 \ --restart=always \ -e "MINIO_ROOT_USER=minioadmin" \ -e "MINIO_ROOT_PASSWORD=minioadmin" \ -v /data/app/minio2/data1:/data1 \ -v /data/app/minio2/data2:/data2 \ -v /data/app/minio2/data3:/data3 \ -v /data/app/minio2/data4:/data4 \ -v /data/app/minio2/data5:/data5 \ -v /data/app/minio2/data6:/data6 \ -v /data/app/minio2/data7:/data7 \ -v /data/app/minio2/data8:/data8 \ -v /data/app/minio2/config:/root/.minio \ --network host \ --hostname "host2" \ minio/minio:latest server \ http://172.16.19.223:9000/data{1...8} \ http://172.16.19.223:9002/data{1...8} \ http://172.16.19.221:9000/data{1...8} \ http://172.16.19.221:9002/data{1...8} \ --console-address ":9092"

  1. 使用docker-compose管理容器:
  2. 创建一个docker-compose.yml文件,写入以下内容:

```yaml version: '3'

services: minio-1: image: minio/minio:latest container_name: minio-1 restart: always environment: - MINIO_ROOT_USER=minioadmin - MINIO_ROOT_PASSWORD=minioadmin volumes: - /data/app/minio1/data1:/data1 - /data/app/minio1/data2:/data2 - /data/app/minio1/data3:/data3 - /data/app/minio1/data4:/data4 - /data/app/minio1/data5:/data5 - /data/app/minio1/data6:/data6 - /data/app/minio1/data7:/data7 - /data/app/minio1/data8:/data8 - /data/app/minio1/config:/root/.minio networks: - minio-network command: server http://172.16.19.223:9000/data{1...8} http://172.16.19.223:9001/data{1...8} http://172.16.19.221:9000/data{1...8} http://172.16.19.221:9001/data{1...8} --console-address ":9090"

minio-2:
  image: minio/minio:latest
  container_name: minio-2
  restart: always
  environment:
    - MINIO_ROOT_USER=minioadmin
    - MINIO_ROOT_PASSWORD=minioadmin
  volumes:
    - /data/app/minio2/data1:/data1
    - /data/app/minio2/data2:/data2
    - /data/app/minio2/data3:/data3
    - /data/app/minio2/data4:/data4
    - /data/app/minio2/data5:/data5
    - /data/app/minio2/data6:/data6
    - /data/app/minio2/data7:/data7
    - /data/app/minio2/data8:/data8
    - /data/app/minio2/config:/root/.minio
  networks:
    - minio-network
  command: server http://172.16.19.223:9000/data{1...8} http://172.16.19.223:9002/data{1...8} http://172.16.19.221:9000/data{1...8} http://172.16.19.221:9002/data{1...8} --console-address ":9091"

networks: minio-network: `` - 运行docker-compose up -d`命令启动docker容器。



【相关推荐】



如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^