如何在MacOS X上的docker上运行spark-notebook?

时间:2015-02-07 12:05:33

标签: apache-spark spark-notebook

在OSX上使用docker运行spark-notebook(通过boot2docker)似乎没有做任何事情。这是输出

pkerp@toc:~/apps/spark-notebook$ docker run -p 9000:9000 andypetrella/spark-notebook:0.1.4-spark-1.2.0-hadoop-1.0.4
Play server process ID is 1
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/docker/lib/spark-repl_2.10-1.2.0-notebook.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/docker/lib/ch.qos.logback.logback-classic-1.1.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/docker/lib/org.slf4j.slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
15/02/07 11:51:32 INFO play: Application started (Prod)
15/02/07 11:51:32 INFO play: Listening for HTTP on /0:0:0:0:0:0:0:0:9000

当我将浏览器指向http://localhost:9000时,表示该网页无法使用。我错过了什么吗?有什么错误的配置吗?

3 个答案:

答案 0 :(得分:7)

使用 boot2docker 运行spark笔记本需要一个额外的命令才能工作。

实际上,docker中的端口转发是不够的,必须在VM级别完成,以使其能够访问主机(localhost / 127.0.0.1)。

这是需要的额外命令: VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port9000,tcp,,9000,,9000"

@see this question了解更多详情。

答案 1 :(得分:0)

使用以下命令运行ipython笔记本

ipython notebook --no-browser --profile=pyspark --ip=*

然后尝试

open http://$(boot2docker ip):8888

有关详细信息,请参阅this post

答案 2 :(得分:0)

如果您收到以下错误:

➜ VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port9000,tcp,,9000,,9000" VBoxManage: error: The machine 'boot2docker-vm' is already locked for a session (or being unlocked) VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Machine, interface IMachine, callee nsISupports VBoxManage: error: Context: "LockMachine(a->session, LockType_Write)" at line 471 of file VBoxManageModifyVM.cpp

您可以通过停止VM,应用更改并再次启动boot2docker来解决此问题...

1)boot2docker stop

2)VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port9000,tcp,,9000,,9000"

3)boot2docker start