version: "3"
services:
hadoop01:
image: yujiangxian/hadoop-basic:master
container_name: master
privileged: true
command: ['/usr/sbin/init']
hostname: master
tty: true
stdin_open: true
ports:
- 50070:50070
- 9870:9870
- 9000:9000
- 8088:8088
- 19888:19888
networks:
net:
ipv4_address: 172.18.0.12
hadoop02:
image: yujiangxian/hadoop-basic:slave1
container_name: slave1
privileged: true
command: ['/usr/sbin/init']
hostname: slave1
tty: true
stdin_open: true
networks:
net:
ipv4_address: 172.18.0.13
hadoop03:
image: yujiangxian/hadoop-basic:slave2
container_name: slave2
privileged: true
command: ['/usr/sbin/init']
tty: true
stdin_open: true
hostname: slave2
networks:
net:
ipv4_address: 172.18.0.14
networks:
net:
driver: bridge
ipam:
config:
- subnet: 172.18.0.0/24
gateway: 172.18.0.1
docker-compose up -d 拉取三镜像并启动容器
docker exec -it 容器名 /bin/bash
cd /root/
source .bash_profile
java -version
systemctl status sshd
最后,hadoop相关软件为了容器大小这里就不放镜像了,需要你们自己添加到容器内
添加命令
docker cp 你的文件路径 容器ID或容器名:容器文件路径
docker pull yujiangxian/hadoop-basic:master
docker pull yujiangxian/hadoop-basic:slave1
docker pull yujiangxian/hadoop-basic:slave2
docker network create -d bridge net --subnet=172.18.0.0/24 --gateway=172.18.0.1
docker run -itd –-privileged=true --name master --hostname master --net docker-hadoopha_net --ip 172.18.0.12 --add-host master:172.18.0.12 -d -p 50070:50070 -p 9870:9870 -p 9000:9000 -p 8088:8088 -p 19888:19888 master /usr/sbin/init
docker exec -it master /bin/bash
初始化环境变量 检验java和ssh服务
cd /root/
source .bash_profile
java -version
systemctl status sshd
docker run -itd --privileged=true --name slave1 --hostname slave1 --net docker-hadoopha_net --ip 172.18.0.13 --add-host slave1:172.18.0.13 -d slave1 /usr/sbin/init
docker exec -it slave1 /bin/bash
初始化环境变量 检验java和ssh服务
cd /root/
source .bash_profile
java -version
systemctl status sshd
docker run -itd --privileged=true --name slave2 --hostname slave2 --net docker-hadoopha_net --ip 172.18.0.14 --add-host slave2:172.18.0.14 -d slave2ssh /usr/sbin/init
docker exec -it slave2 /bin/bash
初始化环境变量 检验java和ssh服务
cd /root/
source .bash_profile
java -version
systemctl status sshd
ERROR: Pool overlaps with other one on this address space
\n
docker network ls 查看有哪些网桥
docker network inspect 你的网桥名字
docker network rm brideg(占用资源网桥名字) 删除占用资源网桥
然后再进行docker-compose up -d
docker network create -d bridge net --subnet=172.18.0.0/24 --gateway=172.18.0.1