vmware + ubuntu + docker+ tensorflow



A. 在vmware里安装ubuntu,login登录后桌面空白的问题。 

    查了很多资料,各种折腾。最后是通过 virtual machine settings --》hardware --》display ,右侧 取消选择 accelerate 3D graphics的复选框解决。


B. 安装docker 

  1. Update the apt package index:

$ sudo apt-get update

Install packages to allow apt to use a repository over HTTPS:

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

Add Docker’s official GPG key:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add 


1.Update the apt package index:


$ sudo apt-get update


2.Install packages to allow apt to use a repository over HTTPS:

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common


3.Add Docker’s official GPG key:

$ gpg --import KEYS
$ sudo apt-get update

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add

Verify that the key fingerprint is 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.

$ sudo apt-key fingerprint 0EBFCD88

pub   4096R/0EBFCD88 2017-02-22
      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid                  Docker Release (CE deb) 
sub   4096R/F273FCD8 2017-02-22


4.

Use the following command to set up the stable repository. You always need thestable repository, even if you want to install builds from theedge or test repositories as well. To add the edge ortest repository, add the word edge ortest (or both) after the wordstable in the commands below.

Note: The lsb_release -cs sub-command below returns the name of your Ubuntu distribution, such asxenial. Sometimes, in a distribution like Linux Mint, you might have to change$(lsb_release -cs) to your parent Ubuntu distribution. For example, if you are usingLinux Mint Rafaela, you could usetrusty.

amd64:

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu  $(lsb_release -cs) stable"
如果出错,将错误信息输入检索。到一个www.digitallocean.com的网站找原语句。


5. 更新apt-get

Update the apt package index.

$ sudo apt-get update


6.  列出所有可用docker版本

On production systems, you should install a specific version of Docker CE instead of always using the latest. This output is truncated. List the available versions.

$ apt-cache madison docker-ce

docker-ce | 17.06.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages


7、安装特定版本

$ sudo apt-get install docker-ce=  

(尖括号去掉 =号后面直接写版本名称)


8. Manage Docker as a non-root user

The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the userroot and other users can only access it usingsudo. The docker daemon always runs as the root user.

If you don’t want to use sudo when you use thedocker command, create a Unix group calleddocker and add users to it. When thedocker daemon starts, it makes the ownership of the Unix socket read/writable by thedocker group.

Warning: The docker group grants privileges equivalent to theroot user. For details on how this impacts security in your system, seeDocker Daemon Attack Surface.

To create the docker group and add your user:

  1. Create the docker group.

    $ sudo groupadd docker
    
  2. Add your user to the docker group.

    $ sudo usermod -aG docker $USER
    
  3. Log out and log back in so that your group membership is re-evaluated.

    If testing on a virtual machine, it may be necessary to restart the virtual machine for changes to take affect.

    On a desktop Linux environment such as X Windows, log out of your session completely and then log back in.

  4. Verify that you can run docker commands without sudo.

    $ docker run hello-world
    

    This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

C. 安装tensorflow

第一次运行该命令,会先从本地查找,本地找不到后会到服务器下载docker的tensorflow镜像。

 sudo docker run -it -p 8888:8888 -p 6006:6006  tensorflow/tensorflow

浏览器打开jupyter notebook http://localhost:8888/   (然后浏览器打开jupyter notebook  http://localhost:8888/?token=98c3d07b555da904d2cd49b032f9d3cbb20aa2a74e681ac3  )    6006是为tensorboard开的端口。

或者

docker run -it gcr.io/tensorflow/tensorflow bash

在命令窗口中运行python指令或程序。   docker exec -i -t 6a86d814de16/bin/bash   (数字ID根据具体机器上的docker container ID来定)  (docker ps 查看所有镜像 )







你可能感兴趣的:(其它)