如何在Windows上构建Docker映像?

时间:2020-07-22 15:01:33

标签: docker

我正在尝试遵循本教程。

https://docs.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-2019

当我运行命令时,我得到

C:\Containers\gitlab docker image>docker build -t buildtools2019:latest -m 2GB .
Sending build context to Docker daemon  3.072kB
Step 1/5 : FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
4.8-windowsservercore-ltsc2019: Pulling from dotnet/framework/sdk
4612f6d0b889: Pulling fs layer                                                                                                                                                                                                               fc1b9e59edad: Pulling fs layer                                                                                                                                                                                                               8a943217e0a7: Pulling fs layer                                                                                                                                                                                                               6dc988e2efd9: Waiting                                                                                                                                                                                                                        4ce1ae7b9cfc: Waiting                                                                                                                                                                                                                        32fad1b53b36: Waiting                                                                                                                                                                                                                        c05f905fc5ae: Waiting                                                                                                                                                                                                                        25d49fe52b1f: Waiting                                                                                                                                                                                                                        d6ea35ae107b: Waiting                                                                                                                                                                                                                        cfe778b81257: Waiting                                                                                                                                                                                                                        ae13fcc9e419: Waiting                                                                                                                                                                                                                        a1183926d84a: Waiting                                                                                                                                                                                                                        23868e77cbc7: Waiting                                                                                                                                                                                                                        6fc097f56a80: Waiting                                                                                                                                                                                                                        83c650a6e15e: Waiting                                                                                                                                                                                                                        image operating system "windows" cannot be used on this platform

上面的错误是由于默认情况下当前容器实例设置为linux。

当我尝试切换容器时,我不断在下面出现以下错误,而docker继续崩溃。

Docker.Core.HttpBadResponseException:
Unhandled exception: Time out has expired and the operation has not been completed.
   at Docker.Core.Logging.ClientExceptionInterceptor.<InterceptResponseAsync>d__0.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.Core\Logging\ClientExceptionInterceptor.cs:line 17
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Docker.Core.Logging.LoggingMessageHandler.<SendAsync>d__4.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.Core\Logging\LoggingMessageHandler.cs:line 37
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Net.Http.HttpClient.<FinishSendAsyncBuffered>d__58.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Docker.Core.BackendAPI.BackendAPIClient.<StartWindowsContainersAsync>d__6.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.Core\BackendAPI\BackendAPIClient.cs:line 53
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Docker.Engines.WindowsContainersEngine.<DoStartAsync>d__12.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\WindowsContainersEngine.cs:line 50
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Docker.ApiServices.StateMachines.TaskExtensions.<WrapAsyncInCancellationException>d__0.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\TaskExtensions.cs:line 29
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Docker.ApiServices.StateMachines.StartTransition.<DoRunAsync>d__5.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\StartTransition.cs:line 67
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Docker.ApiServices.StateMachines.StartTransition.<DoRunAsync>d__5.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\StartTransition.cs:line 92
Original stacktrace:
   at System.ServiceProcess.ServiceController.WaitForStatus(ServiceControllerStatus desiredStatus, TimeSpan timeout)
   at Docker.Backend.Processes.WindowsDockerDaemon.TryToStartService(Settings settings, String args, Dictionary`2 env) in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.Backend\Processes\WindowsDockerDaemon.cs:line 211
   at Docker.Backend.HttpAPI.WindowsContainersController.Start(WindowsContainerStartRequest request) in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.Backend\HttpAPI\WindowsContainersController.cs:line 42
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_1.<GetExecutor>b__0(Object instance, Object[] methodParameters)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()

如何在不使docker崩溃的情况下切换到窗口容器? 很有可能是在我的机器上进行了设置,但是其他人也遇到了同样的问题,如果可以,您是如何解决的?

我运行了有效的docker hello world命令。

docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete                                                                                                                                                                                                                  Digest: sha256:49a1c8800c94df04e9658809b006fd8a686cab8028d33cfba2cc049724254202
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

0 个答案:

没有答案