依据官方文档的指示,我们一步一步来实现它吧
- 1. 概述
- 2. 在Linux上准备好docker环境
- 3. 创建或者下载dockerfile
- 4. 创建镜像
- 5. 运行容器
- 6. 启动H2O
3. 创建或者下载dockerfile本文不对docker的环境准备进行演示,这里推荐一篇文章Linux环境docker安装
确定docker是正常启动状态:
- 在自己的用户目录下准备好一个文件夹,如H2O
- 在该文件夹中自己依据要求创建dockerfile或者直接拉取官方的dockerfile
wget https://raw.githubusercontent.com/h2oai/h2o-3/master/Dockerfile
这里也贴一下dockerfile的内容(注意:不建议从这里复制,因为官方会对dockerfile进行更新):
########################################################################
# Dockerfile for Oracle JDK 8 on Ubuntu 16.04
########################################################################
# pull base image
FROM ubuntu:16.04
# maintainer details
MAINTAINER h2oai "h2o.ai"
# add a post-invoke hook to dpkg which deletes cached deb files
# update the sources.list
# update/dist-upgrade
# clear the caches
RUN
echo 'DPkg::Post-Invoke {"/bin/rm -f /var/cache/apt/archives/*.deb || true";};' | tee /etc/apt/apt.conf.d/no-cache &&
echo "deb http://mirror.math.princeton.edu/pub/ubuntu xenial main universe" >> /etc/apt/sources.list &&
apt-get update -q -y &&
apt-get dist-upgrade -y &&
apt-get clean &&
rm -rf /var/cache/apt/* &&
DEBIAN_FRonTEND=noninteractive apt-get install -y wget unzip openjdk-8-jdk python-pip python-sklearn python-pandas python-numpy python-matplotlib software-properties-common python-software-properties &&
apt-get clean
# Fetch h2o latest_stable
RUN
wget http://h2o-release.s3.amazonaws.com/h2o/latest_stable -O latest &&
wget -i latest -O /opt/h2o.zip &&
unzip -d /opt /opt/h2o.zip &&
rm /opt/h2o.zip &&
cd /opt &&
cd `find . -name 'h2o.jar' | sed 's/.///;s//h2o.jar//g'` &&
cp h2o.jar /opt &&
/usr/bin/pip install `find . -name "*.whl"` &&
printf '!/bin/bashncd /home/h2on./start-h2o-docker.shn' > /start-h2o-docker.sh &&
chmod +x /start-h2o-docker.sh
RUN
useradd -m -c "h2o.ai" h2o
USER h2o
# Get Content
RUN
cd &&
wget https://raw.githubusercontent.com/h2oai/h2o-3/master/docker/start-h2o-docker.sh &&
chmod +x start-h2o-docker.sh &&
wget http://s3.amazonaws.com/h2o-training/mnist/train.csv.gz &&
gunzip train.csv.gz
# Define a mountable data directory
#VOLUME
# ["/data"]
# Define the working directory
WORKDIR
/home/h2o
EXPOSE 54321
EXPOSE 54322
#ENTRYPOINT ["java", "-Xmx4g", "-jar", "/opt/h2o.jar"]
# Define default command
CMD
["/bin/bash"]
4. 创建镜像
docker build -t "h2o.ai/{{branch_name}}:v5" .
注意要保持网络的畅通,如果可以科学上网建议挂上,不然即使更换过了docker的镜像源在一些场景下仍然可能出现连接断开或者拉取特别慢的现象。
可能出现的问题,在执行dockerfile中的wget指令时报出Unable to establish SSL connection错误,这是因为部分网站禁止非浏览器的访问;解决方案:在dockerfile中出现问题的wget指令后加上--no-check-certificate。
docker run -ti -p 54321:54321 h2o.ai/{{branch_name}}:v5 /bin/bash
进入控制台:
-it:表示以交互方式运行容器
-p:接口暴露
接下来依据指示的网址就可以打开H2O的交互式客户端Flow了:



