docker中文文档-windows安装docker

在windows上你可以使用像virtualbox这样的虚拟机,在linux上可以直接使用VM

安装

  1. 安装 virtualbox https://www.virtualbox.org - or follow this tutorial
  1. 安装 vagrant from http://www.vagrantup.com - or follow this tutorial
  1. 安装 git with ssh from http://git-scm.com/downloads - or follow this tutorial

推荐配置2GB内存和2GB的硬盘剩余空间

打开cmd:

启动一个ubuntu服务器

使用安装好的docker下载一个ubuntu镜像

git clone https://github.com/dotcloud/docker.git

cd docker
vagrant up

现在你已经在运行一台ubuntu服务器了,目前还看不到它,因为它在后台运行

 

登录你的ubuntu服务器

登录有2种方式

  • 使用 Vagrant on Windows command prompt OR
  • 使用 SSH

使用 Vagrant on Windows Command Prompt

运行下面的命令

vagrant ssh

你可能看到错误提示 “ssh executable not found”. 这需要你把ssh加入到环境变量,或者你可以直接把git加入到环境变量

set PATH=%PATH%;C:\Program Files (x86)\Git\bin

使用 SSH

首先要获取ubuntu服务器的ip和端口. Simply run:

vagrant ssh-config

你可以看到ssh的相关信息. 比如, HostName is 127.0.0.1 and port is 2222. 用户名是“vagrant”.密码没有显示但是总是默认 “vagrant”.

现在你可以使用给出的ssh信息来登录ssh:

  • 使用 putty.exe 
  • 或者使用 SSH 通过 terminal

使用putty

点击open 输入帐号密码

使用ssh 命令:

你可以使用你喜欢的终端 操作ssh(windows prompt, cygwin, git-bash, …).

ssh vagrant@127.0.0.1 –p 2222

恭喜现在你已经可以登录自己的ubuntu服务器了。

运行 Docker

首先要切换到root用户:

sudo su

现在你可以操作一个 “hello world” 的示例. 运行

docker run busybox echo hello world

完成!

 

排错

VM 无法启动

../../_images/ts_go_bios.JPG

如果你看到这个错误提示 “The VM failed to remain in the ‘running’ state while attempting to boot”, 你需要检查你的 BIOS,看虚拟化设置是否开启. 下面是一个HP电脑的示例 (System configuration / Device configuration)


在bios里找到 virtualization 设置为enable

Docker 没有安装


如果你看到这样的提示 “The program ‘docker’ is currently not installed”, 试着删除docker目录重新安装或者参考Launch an Ubuntu virtual server

 

转载请注明本文链接:http://www.simapple.com/248.html