编写dockerfile
- 从Docker Hub拉取
tensorflow/tensorflow:2.10.0-jupyter
的Docker镜像,里面包含了tensorflow的全部依赖 - 指定工作区目录
- 从requirements.txt获取其他依赖包
- 安装jupyter依赖
- 指定端口
- 配置默认启动命令
FROM tensorflow/tensorflow:2.10.0-jupyter
WORKDIR ~/tf-learning
COPY requirments.txt requirements.txt
RUN pip install jupyter_core --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
RUN pip install mkl mkl_service
EXPOSE 8888
ENTRYPOINT ["jupyter","lab","--ip=0.0.0.0","--allow-root","--no-browser"]
编写requirements.txt
可以将所需安装的pip包放在此处
jupyterlab
pandas
matplotlib
numpy
gensim
joblib
networkx
numba
scipy
scikit-learn
编写docker-compose.yaml文件
描述应用程序的服务、网络、卷等资源,并以声明式的方式定义这些资源如何协同工作
version: '1.0'
services:
jupyter-lab:
build: .
ports:
- "8888:8888"
volumes:
- ~/tf-learning:~/tf-learning
deploy:
resources:
limits:
cpus: "2.00"
memory: 2G