ホームページ  >  記事  >  運用・保守  >  Windows に Docker をインストールする方法に関するコード例の共有

Windows に Docker をインストールする方法に関するコード例の共有

黄舟
黄舟オリジナル
2017-06-07 09:37:042004ブラウズ

Docker for Windows をダウンロード

安定バージョン

Docker for Windows のインストールを準備します
インストール前に、Windows10 のバージョンが 1703 以上であり、OS のバージョンが 15063 以上であることを確認してください
インストールするときバージョン 1607 では、参照アセンブリ ファイルが見つかりません エラー
Docker for Windows が動作するには、Hyper-V パッケージを有効にする必要があります。システムがこれらの要件を満たしていない場合は、Hyper-V の代わりに Oracle Virtual Box を使用する Docker Toolbox をインストールできます。
Windows 10 に Hyper-V URL をインストールします

Windows 用 Docker をインストールします
InstallDocker.msi をダブルクリックしてインストーラーを実行します。

Docker を確認します
PowerShell を開いて次のコードを入力します

PS C:\Users\Docker> docker --version
Docker version 17.03.0-ce, build 60ccb22

PS C:\Users\Docker> docker-compose --version
docker-compose version 1.11.2, build dfed245

PS C:\Users\Docker> docker-machine --version
docker-machine version 0.10.0, build 76ed2a6

docker run hello-world を実行して、Docker Hub からイメージをプルし、コンテナーを起動することをテストします。

PS C:\Users\jdoe> docker run hello-world
Hello from Docker. This message shows that your installation appears
to be working correctly.
To generate this message, Docker took the following steps:
The Docker client contacted the Docker daemon.
The Docker daemon pulled the "hello-world" image from the Docker Hub.
The Docker daemon created a new container from that image which runs the executable that produces the output you are currently
reading.
The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

もっと野心的なことを試して、次のコマンドを使用して Ubuntu コンテナを実行してください。
これにより、ubuntu コンテナー イメージがダウンロードされ、起動されます。以下は、powershell でこのコマンドを実行した場合の出力です。

PS C:Usersjdoe> docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally latest: Pulling from
library/ubuntu 5a132a7e7af1: Pull complete fd2731e4c50c: Pull complete
28a2f68d1120: Pull complete a3ed95caeb02: Pull complete Digest:
sha256:4e85ebe01d056b43955250bbac22bdb8734271122e3c78d21e55ee235fc6802d
Status: Downloaded newer image for ubuntu:latest

dockerを使用してnginxサーバーを起動します

PS C:\Users\jdoe> docker run -d -p 80:80 --name webserver nginx
Unable to find image 'nginx:latest' locally latest: Pulling from
library/nginx
fdd5d7827f33: Pull complete a3ed95caeb02: Pull complete 716f7a5f3082:
Pull complete 7b10f03a0309: Pull complete Digest:
sha256:f6a001272d5d324c4c9f3f183e1b69e9e0ff12debeb7a092730d638c33e0de3e
Status: Downloaded newer image for nginx:latest
dfe13c68b3b86f01951af617df02be4897184cbf7a8b4d5caf1c3c5bd3fc267f
访问http://localhost/以显示nginx起始页。

docker psコマンドを使用してコンテナリストを表示します
dockerimagesコマンドを使用してイメージリストを表示します

アクセラレータ

トレイの右クリックメニューから[設定]を選択しますシステムの右下隅にある アイコンをクリックして、構成ウィンドウを開いて左側に移動し、メニューから [Docker Daemon] を選択します。ウィンドウで JSON 文字列を編集し、Alibaba Cloud、DaoCloud などのアクセラレータ アドレスを次のように入力します:

 {
     "registry-mirrors": [
       "https://sr5arhkn.mirror.aliyuncs.com",
       "http://14d216f4.m.daocloud.io"
     ],
     "insecure-registries": []
   }

以上がWindows に Docker をインストールする方法に関するコード例の共有の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。