docker的安装
#ubuntu
sudo apt-get update # 更新系统资源列表
apt-get -y install docker.io # 安装docker
docker -v # 查看docker版本信息
拉取tensorflow镜像
docker pull tensorflow/tensorflow:latest-py3 #下载最新的tensorflow镜像基于python3
启动容器
docker run -d -it -p 8888:8888 tensorflow/tensorflow #开启jupyter notebook服务,将容器的8888端口映射到本机8888端口
-d:后台运行
-p: 将主机的端口映射到容器的一个端口 主机端口:容器内部的端口
查看启动的容器
docker ps -a
进入镜像
sudo docker exec -it 95d5cc2c422a /bin/bash #ID 输入你自己容器的ID
ls #查看当前目录
cd .. #返回上一层
apt-get update # 更新系统资源列表
apt-get install vi #安装vi
vi run_jupyter.sh
。
删除登陆密码或者修改成固定密码
#!/usr/bin/env bash
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
jupyter notebook "$@"
保存并退出
exit #退出容器
docker restart tensorflow #修改成你自己的容器名
在你的浏览器打开
主机地址:8888
如localhost:8888,便可以访问。