Reputation: 179
Newbie to both Docker and Tensorflow and trying them out. Installation (on win10, using hyper-v driver) went fine and I can run
docker run -p 8888:8888 -it gcr.io/tensorflow/tensorflow
and get output like this:
[I 23:01:01.188 NotebookApp]←(B Serving notebooks from local directory: /notebooks
[I 23:01:01.189 NotebookApp]←(B 0 active kernels
[I 23:01:01.189 NotebookApp]←(B The Jupyter Notebook is running at: http://[all ip addresses on your system]:8888/
[I 23:01:01.189 NotebookApp]←(B Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
and I can open Jupyter notebook from browser by opening [docker host address]:8888.
However, after doing some work (e.g., creating a new notebook), when I stop the server by Ctrl-C twice, all new work are lost. Maybe I'm missing something basic, so let me put what I'm not sure here:
Thanks for your help.
Upvotes: 11
Views: 6663
Reputation: 673
First time, run Docker as a named container in interactive mode. This would give you the link with token. For the subsequent runs, start the container with name. Here is an example:
First run:
$ docker run -p 8888:8888 -d --name <name> gcr.io/tensorflow/tensorflow
When required stop the first run with ctrl-C.
Subsequent runs:
$ docker start <name>
This would automatically run the docker in background mode.
To stop the container:
$ docker stop <name>
Upvotes: 1
Reputation: 1259
I run Docker as a named container:
$ docker run -p 8888:8888 -d --name appu b.gcr.io/tensorflow-udacity/assignments
appu
is the name I have given to my container.
-p
forwards port number 8888 from Linux to Windows.
-d
makes the program run in the background, so that you get the $
prompt on your console and can continue to work with other tasks (this is what is called 'demonizing', but don't be intimidated by geeks. It just means 'please run silently in the background, and give me back my console' !)
When you want to stop the container, mention it by name
$ docker stop appu
Next time you want to get the same container back, with all the files you created in your earlier session, start the container appu again:
$ docker start appu
Upvotes: 5
Reputation: 81
You can mount current host folder to replace the default /notebooks
folder in the container. Here is an example:
$ docker run -p 8888:8888 -v `pwd`:/notebooks -it gcr.io/tensorflow/tensorflow
[I 02:34:49.393 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 02:34:49.411 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 02:34:49.420 NotebookApp] Serving notebooks from local directory: /notebooks
[I 02:34:49.421 NotebookApp] 0 active kernels
[I 02:34:49.421 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:8888/?token=b9da5de7f61d6a968dc07e55c6157606a4f2f378cd764a91
[I 02:34:49.421 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 02:34:49.422 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=b9da5de7f61d6a968dc07e55c6157606a4f2f378cd764a91
Upvotes: 8
Reputation: 3416
You want run the container as a daemon. Then you can docker stop
and docker start
the container and retrieve your work.
docker run -td -p 8888:8888 gcr.io/tensorflow/
Running with -it
makes the container interactive and run in the foreground which is why the work is lost when you cancel it. Best practice and run it as a daemon so you don't have to CTRL+C to quit and can instead let docker handle the state.
Upvotes: 7