github.com/tompao/docker@v1.9.1/docs/installation/windows.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Installation on Windows"
     4  description = "Docker installation on Microsoft Windows"
     5  keywords = ["Docker, Docker documentation, Windows, requirements, virtualbox,  boot2docker"]
     6  [menu.main]
     7  parent = "smn_engine"
     8  +++
     9  <![end-metadata]-->
    10  
    11  # Windows
    12  
    13  > **Note**: This release of Docker deprecates the Boot2Docker command line in
    14  > favor of Docker Machine.  Use the Docker Toolbox to install Docker Machine as
    15  > well as the other Docker tools.
    16  
    17  You install Docker using Docker Toolbox. Docker Toolbox includes the following Docker tools:
    18  
    19  * Docker Machine for running the `docker-machine` binary
    20  * Docker Engine for running the `docker` binary
    21  * Kitematic, the Docker GUI
    22  * a shell preconfigured for a Docker command-line environment
    23  * Oracle VM VirtualBox
    24  
    25  Because the Docker daemon uses Linux-specific kernel features, you can't run
    26  Docker natively in Windows. Instead, you must use `docker-machine` to create and attach to a Docker VM on your machine. This VM hosts Docker for you on your Windows system.
    27  
    28  The Docker VM is lightweight Linux virtual machine made specifically to run the
    29  Docker daemon on Windows. The VirtualBox VM runs completely from RAM, is a
    30  small ~24MB download, and boots in approximately 5s.
    31  
    32  ## Requirements
    33  
    34  Your machine must be running Windows 7, 8/8.1 or newer to run Docker. Windows 10 is not currently supported. To find out what version of Windows you have:
    35  
    36  1. Right click the Windows Start Menu and choose **System**.
    37  
    38      ![Which version](images/win_ver.png)
    39  
    40      If you are using an unsupported version of Windows, you should consider
    41      upgrading your operating system in order to try out Docker.
    42  
    43  2. Make sure your CPU supports [virtualization technology](https://en.wikipedia.org/wiki/X86_virtualization)
    44  and virtualization support is enabled in BIOS and recognized by Windows.
    45  
    46      #### For Windows 8 or 8.1
    47  
    48  	  Choose **Start > Task Manager** and navigate to the **Performance** tab.
    49  	  Under **CPU** you should see the following:
    50  
    51        ![Release page](images/virtualization.png)
    52  
    53      If virtualization is not enabled on your system, follow the manufacturer's instructions for enabling it.
    54  
    55      #### For Windows 7
    56  
    57  	  Run the <a
    58  	  href="http://www.microsoft.com/en-us/download/details.aspx?id=592"
    59  	  target="_blank"> Microsoft® Hardware-Assisted Virtualization Detection
    60  	  Tool</a> and follow the on-screen instructions.
    61  
    62  
    63  > **Note**: If you have Docker hosts running and you don't wish to do a Docker Toolbox
    64  installation, you can install the `docker.exe` using the *unofficial* Windows package
    65  manager Chocolately. For information on how to do this, see [Docker package on
    66  Chocolatey](http://chocolatey.org/packages/docker).
    67  
    68  ### Learn the key concepts before installing
    69  
    70  In a Docker installation on Linux, your machine is both the localhost and the
    71  Docker host. In networking, localhost means your computer. The Docker host is
    72  the machine on which the containers run.
    73  
    74  On a typical Linux installation, the Docker client, the Docker daemon, and any
    75  containers run directly on your localhost. This means you can address ports on a
    76  Docker container using standard localhost addressing such as `localhost:8000` or
    77  `0.0.0.0:8376`.
    78  
    79  ![Linux Architecture Diagram](images/linux_docker_host.svg)
    80  
    81  In an Windows installation, the `docker` daemon is running inside a Linux virtual
    82  machine. You use the Windows Docker client to talk to the Docker host VM. Your
    83  Docker containers run inside this host.
    84  
    85  ![Windows Architecture Diagram](images/win_docker_host.svg)
    86  
    87  In Windows, the Docker host address is the address of the Linux VM. When you
    88  start the VM with `docker-machine` it is assigned an IP address. When you start
    89  a container, the ports on a container map to ports on the VM. To see this in
    90  practice, work through the exercises on this page.
    91  
    92  
    93  ### Installation
    94  
    95  If you have VirtualBox running, you must shut it down before running the
    96  installer.
    97  
    98  1. Go to the [Docker Toolbox](https://www.docker.com/toolbox) page.
    99  
   100  2. Click the installer link to download.
   101  
   102  3. Install Docker Toolbox by double-clicking the installer.
   103  
   104      The installer launches the "Setup - Docker Toolbox" dialog.
   105  
   106      ![Install Docker Toolbox](images/win-welcome.png)
   107  
   108  4. Press "Next" to install the toolbox.
   109  
   110      The installer presents you with options to customize the standard
   111      installation. By default, the standard Docker Toolbox installation:
   112  
   113      * installs executables for the Docker tools in `C:\Program Files\Docker Toolbox`
   114      * install VirtualBox; or updates any existing installation
   115      * adds a Docker Inc. folder to your program shortcuts
   116      * updates your `PATH` environment variable
   117      * adds desktop icons for the Docker Quickstart Terminal and Kitematic
   118  
   119      This installation assumes the defaults are acceptable.
   120  
   121  5. Press "Next" until you reach the "Ready to Install" page.
   122  
   123       The system prompts you for your password.
   124  
   125       ![Install](images/win-page-6.png)
   126  
   127  6. Press "Install"  to continue with the installation.
   128  
   129       When it completes, the installer provides you with some information you can
   130       use to complete some common tasks.
   131  
   132       ![All finished](images/windows-finish.png)
   133  
   134  7. Press "Finish" to exit.
   135  
   136  ## Running a Docker Container
   137  
   138  To run a Docker container, you:
   139  
   140  * create a new (or start an existing) Docker virtual machine
   141  * switch your environment to your new VM
   142  * use the `docker` client to create, load, and manage containers
   143  
   144  Once you create a machine, you can reuse it as often as you like. Like any
   145  VirtualBox VM, it maintains its configuration between uses.
   146  
   147  There are several ways to use the installed tools, from the Docker Quickstart Terminal or
   148  [from your shell](#from-your-shell).
   149  
   150  ### Using the Docker Quickstart Terminal
   151  
   152  1. Find the Docker Quickstart Terminal icon on your Desktop and double-click to launch it.
   153  
   154      The application:
   155  
   156      * opens a terminal window
   157      * creates a `default` VM if it doesn't exist, and starts the VM after
   158      * points the terminal environment to this VM
   159  
   160      Once the launch completes, you can run `docker` commands.
   161  
   162  3. Verify your setup succeeded by running the `hello-world` container.
   163  
   164          $ docker run hello-world
   165          Unable to find image 'hello-world:latest' locally
   166          511136ea3c5a: Pull complete
   167          31cbccb51277: Pull complete
   168          e45a5af57b00: Pull complete
   169          hello-world:latest: The image you are pulling has been verified.
   170          Important: image verification is a tech preview feature and should not be
   171          relied on to provide security.
   172          Status: Downloaded newer image for hello-world:latest
   173          Hello from Docker.
   174          This message shows that your installation appears to be working correctly.
   175  
   176          To generate this message, Docker took the following steps:
   177          1. The Docker client contacted the Docker daemon.
   178          2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
   179             (Assuming it was not already locally available.)
   180          3. The Docker daemon created a new container from that image which runs the
   181             executable that produces the output you are currently reading.
   182          4. The Docker daemon streamed that output to the Docker client, which sent it
   183             to your terminal.
   184  
   185          To try something more ambitious, you can run an Ubuntu container with:
   186          $ docker run -it ubuntu bash
   187  
   188          For more examples and ideas, visit:
   189          http://docs.docker.com/userguide/
   190  
   191  
   192  ### Using Docker from Windows Command Prompt (cmd.exe)
   193  
   194  1. Launch a Windows Command Prompt (cmd.exe).
   195  
   196      The `docker-machine` command requires `ssh.exe` in your `PATH` environment
   197      variable. This `.exe` is in the MsysGit `bin` folder.
   198  
   199  2. Add this to the `%PATH%` environment variable by running:
   200  
   201          set PATH=%PATH%;"c:\Program Files (x86)\Git\bin"
   202  
   203  3. Create a new Docker VM.
   204  
   205          docker-machine create --driver virtualbox my-default
   206          Creating VirtualBox VM...
   207          Creating SSH key...
   208          Starting VirtualBox VM...
   209          Starting VM...
   210          To see how to connect Docker to this machine, run: docker-machine env my-default
   211  
   212      The command also creates a machine configuration in the
   213      `C:\USERS\USERNAME\.docker\machine\machines` directory. You only need to run the `create`
   214      command once. Then, you can use `docker-machine` to start, stop, query, and
   215      otherwise manage the VM from the command line.
   216  
   217  4. List your available machines.
   218  
   219          C:\Users\mary> docker-machine ls
   220          NAME                ACTIVE   DRIVER       STATE     URL                         SWARM
   221          my-default        *        virtualbox   Running   tcp://192.168.99.101:2376
   222  
   223      If you have previously installed the deprecated Boot2Docker application or
   224      run the Docker Quickstart Terminal, you may have a `dev` VM as well.
   225  
   226  5. Get the environment commands for your new VM.
   227  
   228          C:\Users\mary> docker-machine env --shell cmd my-default
   229  
   230  6. Connect your shell to the `my-default` machine.
   231  
   232          C:\Users\mary> eval "$(docker-machine env my-default)"
   233  
   234  7. Run the `hello-world` container to verify your setup.
   235  
   236          C:\Users\mary> docker run hello-world
   237  
   238  ### Using Docker from PowerShell
   239  
   240  1. Launch a Windows PowerShell window.
   241  
   242  2. Add `ssh.exe` to your PATH:
   243  
   244          PS C:\Users\mary> $Env:Path = "${Env:Path};c:\Program Files (x86)\Git\bin"
   245  
   246  3. Create a new Docker VM.
   247  
   248          PS C:\Users\mary> docker-machine create --driver virtualbox my-default
   249  
   250  4. List your available machines.
   251  
   252          C:\Users\mary> docker-machine ls
   253          NAME                ACTIVE   DRIVER       STATE     URL                         SWARM
   254          my-default        *        virtualbox   Running   tcp://192.168.99.101:2376
   255  
   256  5. Get the environment commands for your new VM.
   257  
   258          C:\Users\mary> docker-machine env --shell powershell my-default
   259  
   260  6. Connect your shell to the `my-default` machine.
   261  
   262          C:\Users\mary> eval "$(docker-machine env my-default)"
   263  
   264  7. Run the `hello-world` container to verify your setup.
   265  
   266          C:\Users\mary> docker run hello-world
   267  
   268  
   269  ## Learn about your Toolbox installation
   270  
   271  Toolbox installs the Docker Engine binary in the `C:\Program Files\Docker
   272  Toolbox` directory. When you use the Docker Quickstart Terminal or create a
   273  `default` VM manually, Docker Machine updates the
   274  `C:\USERS\USERNAME\.docker\machine\machines\default` folder to your
   275  system. This folder contains the configuration for the VM.
   276  
   277  You can create multiple VMs on your system with Docker Machine. Therefore, you
   278  may end up with multiple VM folders if you have created more than one VM. To
   279  remove a VM, use the `docker-machine rm <machine-name>` command.
   280  
   281  ## Migrate from Boot2Docker
   282  
   283  If you were using Boot2Docker previously, you have a pre-existing Docker
   284  `boot2docker-vm` VM on your local system.  To allow Docker Machine to manage
   285  this older VM, you can migrate it.
   286  
   287  1. Open a terminal or the Docker CLI on your system.
   288  
   289  2. Type the following command.
   290  
   291          $ docker-machine create -d virtualbox --virtualbox-import-boot2docker-vm boot2docker-vm docker-vm
   292  
   293  3. Use the `docker-machine` command to interact with the migrated VM.
   294  
   295  The `docker-machine` subcommands are slightly different than the `boot2docker`
   296  subcommands. The table below lists the equivalent `docker-machine` subcommand
   297  and what it does:
   298  
   299  |  `boot2docker` | `docker-machine` | `docker-machine` description                             |
   300  |----------------|------------------|----------------------------------------------------------|
   301  | init           | create           | Creates a new docker host.                               |
   302  | up             | start            | Starts a stopped machine.                                |
   303  | ssh            | ssh              | Runs a command or interactive ssh session on the machine.|
   304  | save           | -                | Not applicable.                                          |
   305  | down           | stop             | Stops a running machine.                                 |
   306  | poweroff       | stop             | Stops a running machine.                                 |
   307  | reset          | restart          | Restarts a running machine.                              |
   308  | config         | inspect          | Prints machine configuration details.                    |
   309  | status         | ls               | Lists all machines and their status.                     |
   310  | info           | inspect          | Displays a machine's details.                            |
   311  | ip             | ip               | Displays the machine's ip address.                       |
   312  | shellinit      | env              | Displays shell commands needed to configure your shell to interact with a machine |
   313  | delete         | rm               | Removes a machine.                                       |
   314  | download       | -                | Not applicable.                                          |
   315  | upgrade        | upgrade          | Upgrades a machine's Docker client to the latest stable release. |
   316  
   317  
   318  ## Upgrade Docker Toolbox
   319  
   320  To upgrade Docker Toolbox, download an re-run [the Docker Toolbox
   321  installer](https://www.docker.com/toolbox).
   322  
   323  ## Container port redirection
   324  
   325  If you are curious, the username for the Docker default VM is `docker` and the
   326  password is `tcuser`. The latest version of `docker-machine` sets up a host only
   327  network adaptor which provides access to the container's ports.
   328  
   329  If you run a container with a published port:
   330  
   331      $ docker run --rm -i -t -p 80:80 nginx
   332  
   333  Then you should be able to access that nginx server using the IP address
   334  reported to you using:
   335  
   336      $ docker-machine ip
   337  
   338  Typically, the IP is 192.168.59.103, but it could get changed by VirtualBox's
   339  DHCP implementation.
   340  
   341  ## Login with PUTTY instead of using the CMD
   342  
   343  Docker Machine generates and uses the public/private key pair in your
   344  `%USERPROFILE%\.ssh` directory so to log in you need to use the private key from
   345  this same directory. The private key needs to be converted into the format PuTTY
   346  uses. You can do this with
   347  [puttygen](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html):
   348  
   349  1. Open `puttygen.exe` and load ("File"->"Load" menu) the private key from
   350  
   351          %USERPROFILE%\.docker\machine\machines\<name_of_your_machine>
   352  
   353  2. Click "Save Private Key".
   354  
   355  3.  Use the saved file to login with PuTTY using `docker@127.0.0.1:2022`.
   356  
   357  ## Uninstallation
   358  
   359  You can uninstall Docker Toolbox using Window's standard process for removing
   360  programs. This process does not remove the `docker-install.exe` file. You must
   361  delete that file yourself.
   362  
   363  ## Learn more
   364  
   365  You can continue with the [Docker User Guide](../userguide). If you are
   366  interested in using the Kitematic GUI, see the [Kitematic user
   367  guide](https://docs.docker.com/kitematic/userguide/).