在使用https://github.com/kiwenlau/hadoop-cluster-docker 搭建完成集群hadoop后,我在mac上开发,发现无法操作docker容器中的Hdfs,原因可能是无法ping通 容器ip,导致无法连接到hdfs
Configuration configuration = new Configuration();
FileSystem fs = FileSystem.get(new URI("hdfs://172.18.0.2:9000/"), configuration, "root");
System.out.println("begin copy");
// fs.copyToLocalFile(new Path("/run-wordcount.sh"),new Path("/Users/xiaxiang/apps/test/run-wordcount.sh"));
fs.copyFromLocalFile(new Path("/Users/xiaxiang/main.lua"), new Path("/"));
System.out.println("done!");
fs.close();
即使在docker启动容器的时候讲端口映射到容器内部端口,比如:
sudo docker run -itd \