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

How to run spark-notebook on docker on MacOS X?

运行 在 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 时,它说该网页不可用。我错过了什么吗?是不是配置有误?

运行 使用 boot2docker 的 spark notebook 需要额外的命令才能工作。

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

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

@有关详细信息,请参阅 this question

运行 ipython notebook 使用以下命令

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

然后尝试

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

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

如果出现以下错误:

➜ 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