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