Install docker on Windows Server system

服务器版本docker安装教程

Reference in Chinese:
[1]https://blog.csdn.net/weixin_47425074/article/details/139064776
[2]https://www.cnblogs.com/a120608yby/p/17880004.html

To use docker on Windows Server system, you have to install the “docker-ee” edtion(Docker Enterprise Edition) instead of the desktop client(which is referred to as “docker-ce”) for personal usage.

  • Start and check the “Hyper-V” and “container” services in the server manager of control panel. Restart the server(computer) after this step.
    Container service[1]

  • Download the docker setup package from this link:
    https://download.docker.com/win/static/stable/x86_64/
    An important note: The Windows server system deployed in our group is kind of out of date. Therefore it is important not to download the latest version of docker from the site to avoid Errors in the installation process.

  • Decompress the downloaded file to your desired position and configure the corresponding environment variables:
    Environment variables[2]

  • Register the docker service(Run CMD as administrator)

    1
    dockerd --register-service
  • Start the docker service(Run PowerShell as administrator)

    1
    Start-Service docker

    If no error message appears, the docker is successfully deployed on your system.

  • Configure the daemon.json(For Chinese users only)(创建 C:\ProgramData\Docker\config 目录,在config目录下创建 daemon.json 文件)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
        {
    "registry-mirrors": [
    "https://docker.mirrors.ustc.edu.cn",
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com",
    "https://mirror.ccs.tencentyun.com"
    ],
    "insecure-registries": ["127.0.0.1/8", "reg.example.com"],
    "data-root": "d:\\docker"
    }
  • Restart the service (Run PowerShell as administrator):

    1
    Restart-Service docker
  • Set automatic startup:
    Run PowerShell as administrator

    1
    Set-Service docker -StartupType Automatic
  • When docker service fails to start, the “docker engine“ log can be obtained in PowerShell as follows: (For example, incompatibility between docker and my system version is encountered in my case(4 fatal: failed to start daemon: this version of Windows does not support…). The docker log provides clear and helpful information. This tool is really useful.)

    1
    Get-EventLog -LogName Application -Source Docker
  • Reinstall and register the docker service (PowerShell):

    • Stop and remove the current docker service:
      1
      sc.exe delete docker
      This will remove the current docker service, including the accompanying registry entries. To ensure a complete delete, it is then suggested to remove these registry entries manually.
      1
      2
      3
      4
      Press "Win + R" to open the "Run" dialog. Then enter "regedit" to open the Registry Editor.  
      Navigate to the following position:
      HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\docker
      Right click the "docker" folder and delete it.
    • Then register the docker service again:
      1
      dockerd --register-service
    • If everything goes well, you can now start the docker service:
      1
      Start-Service docker