Giter Site home page Giter Site logo

sixeyed / docker-on-windows Goto Github PK

View Code? Open in Web Editor NEW
229.0 28.0 125.0 6.08 MB

Code samples for the book "Docker on Windows"

Home Page: https://www.amazon.com/gp/product/1789617375/

License: Apache License 2.0

PowerShell 1.11% C# 12.42% CSS 30.94% JavaScript 49.19% HTML 4.86% ASP 0.12% Gherkin 0.01% Dockerfile 1.09% TSQL 0.26%
docker dockerfile windows swarm asp-net dotnet

docker-on-windows's Introduction

Docker on Windows

This is all the source code for the samples in my book Docker on Windows, published by Packt.

There are two editions of the book. This is the latest edition, which covers Docker on Windows Server 2019, and that's what you should be using. If you're still using Windows Server 2016 then you want the first edition.

Every Dockerfile is in this repo, and all the images are also available on Docker Hub at the dockeronwindows organization.

It's a comprehensive look at running Docker on Windows, covering everything from 101 to production over 12 chapters.

Weekly Dockerfile

I've also got a blog series describing all the Dockerfiles in detail: Weekly Windows Dockerfiles

The Missing Preface

Somewhere between the author's laptop, the publisher's content system and the printing press, the preface I wrote didn't make it into the final book. You can read it here.

Contents

  1. Getting Started with Docker on Windows

  2. Packaging and Running Applications as Docker Containers

  3. Developing Dockerized .NET and .NET Core Applications

  4. Pushing and Pulling Images from Docker Registries

  5. Adopting Container-First Solution Design

  6. Organizing Distributed Solutions with Docker Compose

  7. Orchestrating Distributed Solutions with Docker Swarm

  8. Administering and Monitoring Dockerized Solutions

  9. Understanding the Security Risks and Benefits of Docker

  10. Powering a Continuous Deployment Pipeline with Docker

  11. Debugging and Instrumenting Application Containers

  12. Containerize What You Know: Guidance for Implementing Docker

Cover Art

Docker on Windows by Elton Stoneman, cover page

Reviews

docker-on-windows's People

Contributors

grahamdsmith avatar james-world avatar kkbruce avatar sixeyed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-on-windows's Issues

Secrets on Windows

Do you think it will be good/viable solution instead of modifying code to accomodate for docker secrets instead have all secret management as part of Entrypoint dockerfile reference. That is to have logic in Entrypoint to import/modify secrets at container start and update relevant web.config, configuration references. This

  1. Do not require modification of application pool RunAs or any other security aspects of running application since EntryPoint is executed as ContainerAdmin
  2. Do not require any source code modification

ch05 reverse-proxy has problems

Hello,

Thank you for an excellent book. I have been reading and following through your examples and through the standardization that Docker provides, the examples still run as expected.

However, in Ch5, when I run ch05-run-nerd-dinner_part-2.ps1 ( after part-1 ), I noticed that while the reverse-proxy service does run, the transcript indicates some errors.
Log:
1 > time="2021-01-16T18:11:08-08:00" level=error msg="Failed to retrieve information of the docker client and server host: error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version: open //./pipe/docker_engine: message readmode pipes not supported In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running."
2 > time="2021-01-16T18:11:08-08:00" level=error msg="Provider connection error Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version: open //./pipe/docker_engine: message readmode pipes not supported In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.

github.com/containous/traefik/vendor/github.com/docker/docker/client.(*Client).doRequest
/go/src/github.com/containous/traefik/vendor/github.com/docker/docker/client/request.go:182
github.com/containous/traefik/vendor/github.com/docker/docker/client.(*Client).sendRequest
/go/src/github.com/containous/traefik/vendor/github.com/docker/docker/client/request.go:122
github.com/containous/traefik/vendor/github.com/docker/docker/client.(*Client).get
/go/src/github.com/containous/traefik/vendor/github.com/docker/docker/client/request.go:37
github.com/containous/traefik/vendor/github.com/docker/docker/client.(*Client).ServerVersion
/go/src/github.com/containous/traefik/vendor/github.com/docker/docker/client/version.go:12
github.com/containous/traefik/provider/docker.(*Provider).Provide.func1.1
/go/src/github.com/containous/traefik/provider/docker/docker.go:137
github.com/containous/traefik/safe.OperationWithRecover.func1
/go/src/github.com/containous/traefik/safe/routine.go:160
github.com/containous/traefik/vendor/github.com/cenk/backoff.RetryNotify
/go/src/github.com/containous/traefik/vendor/github.com/cenk/backoff/retry.go:37
github.com/containous/traefik/provider/docker.(*Provider).Provide.func1
/go/src/github.com/containous/traefik/provider/docker/docker.go:252
github.com/containous/traefik/safe.(*Pool).GoCtx.func1
/go/src/github.com/containous/traefik/safe/routine.go:62
github.com/containous/traefik/safe.GoWithRecover.func1
/go/src/github.com/containous/traefik/safe/routine.go:142
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1333
error during connect
github.com/containous/traefik/vendor/github.com/docker/docker/client.(*Client).doRequest
/go/src/github.com/containous/traefik/vendor/github.com/docker/docker/client/request.go:185
github.com/containous/traefik/vendor/github.com/docker/docker/client.(*Client).sendRequest
/go/src/github.com/containous/traefik/vendor/github.com/docker/docker/client/request.go:122
github.com/containous/traefik/vendor/github.com/docker/docker/client.(*Client).get
/go/src/github.com/containous/traefik/vendor/github.com/docker/docker/client/request.go:37
github.com/containous/traefik/vendor/github.com/docker/docker/client.(*Client).ServerVersion
/go/src/github.com/containous/traefik/vendor/github.com/docker/docker/client/version.go:12
github.com/containous/traefik/provider/docker.(*Provider).Provide.func1.1
/go/src/github.com/containous/traefik/provider/docker/docker.go:137
github.com/containous/traefik/safe.OperationWithRecover.func1
/go/src/github.com/containous/traefik/safe/routine.go:160
github.com/containous/traefik/vendor/github.com/cenk/backoff.RetryNotify
/go/src/github.com/containous/traefik/vendor/github.com/cenk/backoff/retry.go:37
github.com/containous/traefik/provider/docker.(*Provider).Provide.func1
/go/src/github.com/containous/traefik/provider/docker/docker.go:252
github.com/containous/traefik/safe.(*Pool).GoCtx.func1
/go/src/github.com/containous/traefik/safe/routine.go:62
github.com/containous/traefik/safe.GoWithRecover.func1
/go/src/github.com/containous/traefik/safe/routine.go:142
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1333, retrying in 369.950822ms"

Here is my Docker host environment :
Powershell : run as an Administrator, with ExecutionPolicy = RemoteSigned, All.
PC: Windows 10, 2004
Docker Desktop: 3.0.4
Docker Engine: 20.10.2

Tried the following :

  1. Added --isolation hyperv option to Docker run did not work
    Based on StefanScherer/dockerfiles-windows#383

2.Substitute sixeyed/traefik:v1.7.8-windowsservercore-ltsc2019 for a newer Traefix traefik:v2.3.7-windowsservercore-1809 failed with error :

2021/01/16 21:13:12 command traefik error: failed to decode configuration from flags: field not found, node: docker
This tells me that I should look at the Dockerfile for sixeyed/traefik:v1.7.8-windowsservercore-ltsc2019 to find out how the --docker flag should be handled.

Unfortunately sixeyed/traefik is a container, not an image and does not have the Dockerfile available for inspection.

Hopefully, you can provide some guidance to get your example working again.

Thanks,

Traefik using named pipes in swarm mode

Hi Elton,
In chapter 7 you tell the swarm mode would be available until the release of the book.
I'm trying with the same docker-compose form local but it's not working.
I just want to check if my versions are correct to try this.
Docker: 19.03.2
Windows: Windows Server 2019 Datacenter Version 1809 (OS Build 17763.737)
Thanks.

CH03 - nerd-dinner-web

When trying to run the container ch-03-nerd-dinner-web I'm receiving the error below (the same as the last issue):
PS C:\DockerStudy\ch03\ch03-nerd-dinner-web> docker container logs 596bb08cab53

_Invoke-WebRequest : Unable to connect to the remote server
At line:1 char:180

  • ... w3svc; Invoke-WebRequest http://localhost -UseBasicParsing | Out ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:Htt
      pWebRequest) [Invoke-WebRequest], WebException
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShe
      ll.Commands.InvokeWebRequestCommand

Get-Content : Cannot find path 'C:\iislog\W3SVC\u_extend1.log' because it does
not exist.
At line:1 char:291

  • ... t-Null; Get-Content -path 'C:\iislog\W3SVC\u_extend1.log' -Tail 1 ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (C:\iislog\W3SVC\u_extend1.log:S
      tring) [Get-Content], ItemNotFoundException
    • FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCo
      ntentCommand_

Linux container on windows server 2019

I was wondering if there is a book or more materials where someone could get more information about running linux containers on windows server 2019. Couldn't get more info by reading this book. Thanks in advance for any feedback.

Running docker build on ch03-iis-healthcheck results in build failure at step 6/16

Output is:

Step 6/16 : RUN msbuild Healthcheck.WebApi.csproj /p:OutputPath=c:\out\Healthcheck /p:DeployOnBuild=true /p:VSToolsPath=C:\MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3\tools\VSToolsPath
---> Running in 82394ec8732a
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 12/16/2017 5:35:27 PM.
Project "C:\src\Healthcheck.WebApi\Healthcheck.WebApi.csproj" on node 1 (default targets).
C:\src\Healthcheck.WebApi\Healthcheck.WebApi.csproj(139,5): error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props.
Done Building Project "C:\src\Healthcheck.WebApi\Healthcheck.WebApi.csproj" (default targets) -- FAILED.

Build FAILED.

I've done some research but not got to the bottom of this yet, however this StackOverflow question seems to be related. I can't get the source code to compile locally because of this error but possibly due to not having the right VS2017 components installed. I've run out of time tonight but wanted to get this logged. Cheers!

CH03 - iis-healthcheck

Running the command:
docker container run -d -P --name healthcheck dockeronwindows/ch03-iis-healthcheck:2e

Container starts and stop in seconds. The log from the docker container log:

_Invoke-WebRequest : Unable to connect to the remote server
At line:1 char:180

  • ... w3svc; Invoke-WebRequest http://localhost/diagnostics -UseBasicP ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:Htt
      pWebRequest) [Invoke-WebRequest], WebException
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShe
      ll.Commands.InvokeWebRequestCommand

Get-Content : Cannot find path 'C:\iislog\W3SVC\u_extend1.log' because it does
not exist.
At line:1 char:303

  • ... t-Null; Get-Content -path 'C:\iislog\W3SVC\u_extend1.log' -Tail 1 ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (C:\iislog\W3SVC\u_extend1.log:S
      tring) [Get-Content], ItemNotFoundException
    • FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCo
      ntentCommand_

How do you reboot a Windows Container?

Hi Elton

I need to change the locale of a Windows Container. I know it requires a reboot of a normal Windows machine or VM. How do I do the same with a Docker Container?

I've tried restart-computer but that produces errors on shutdown so the container can't be restarted.

So how is it done?

nuget restore fail ,how to fix

Step 4/16 : RUN nuget restore packages.config -PackagesDirectory ..\packages
---> Running in e3433b4bdf8f
Restoring NuGet package Microsoft.AspNet.WebApi.5.2.3.
Restoring NuGet package Microsoft.AspNet.WebApi.Client.5.2.3.
Restoring NuGet package Microsoft.AspNet.WebApi.Core.5.2.3.
Restoring NuGet package Microsoft.AspNet.WebApi.WebHost.5.2.3.
Restoring NuGet package Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0.
Restoring NuGet package Newtonsoft.Json.6.0.4.
WARNING: Unable to find version '5.2.3' of package 'Microsoft.AspNet.WebApi.Client'.
C:\Users\ContainerAdministrator.nuget\packages: Package 'Microsoft.AspNet.WebApi.Client.5.2.3' is not found on source 'C:\Users\ContainerAdministrator.nuget\packages'.
https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.
An error occurred while sending the request.
The remote name could not be resolved: 'api.nuget.org'

G drive solution not work for nodejs inside mount volume in windows container

issue
Use windows nodejs image (server core in 1803/1809) to build html source code in a mount volume(docker volume, host-volume and G driver solution), all build in mount volume are failure when in lerna bootstrap with the same kind of Error "Error: EPERM: operation not permitted, symlink".

Expected behavior
Use windows nodejs image to build source code in a mount volume, npm install successfully

Actual behavior
npm WARN [email protected] requires a peer of zone.js@^0.8.29 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\json-sass\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

  • [email protected]
    added 2008 packages from 1982 contributors in 166.342s
    npm timing npm Completed in 166795ms
    npm info ok
    "Deleting current lerna json file"
    "Copying lerna-bootstrap.json to current folder"
    1 file(s) copied.
    "rename lerna-bootstrap.json to lerna.json"
    lerna info version 2.11.0
    lerna info versioning independent
    lerna info scope @wuitk6/*
    lerna info Bootstrapping 7 packages
    lerna info lifecycle preinstall
    lerna WARN EHOIST_ROOT_VERSION The repository root depends on @types/d3@^3.5.41, which differs from the more common @types/d3@^3.5.38.
    lerna WARN EHOIST_PKG_VERSION "@wuitk6/examples" package depends on @types/d3@^3.5.38, which differs from the hoisted @types/d3@^3.5.41.
    lerna WARN EHOIST_PKG_VERSION "@wuitk6/gallery" package depends on @types/d3@^3.5.38, which differs from the hoisted @types/d3@^3.5.41.
    lerna info Installing external dependencies
    lerna info hoist Installing hoisted dependencies into root
    lerna info hoist Pruning hoisted dependencies
    lerna info hoist Finished pruning hoisted dependencies
    lerna info hoist Finished installing in root
    lerna info Symlinking packages and binaries
    lerna ERR! execute callback with error
    lerna ERR!
    { [Error: EPERM: operation not permitted, symlink 'C:\data\uid-web\packages\core' -> 'C:\data\uid-web\packages\angular\node_modules@wuitk6\core']
    errno: -4048,
    code: 'EPERM',
    syscall: 'symlink',
    path: 'C:\data\uid-web\packages\core',
    dest:
    'C:\data\uid-web\packages\angular\node_modules\@wuitk6\core',
    exitCode: 1 }
    error in lerna bootstrap

Environment Information
Windows Version: windows 10 1809
Docker Desktop Version: 19.03.2

docker file
you can find docker file from https://raw.githubusercontent.com/StefanScherer/dockerfiles-windows/master/node/10/Dockerfile, only add below 2 line for your G drive solution

VOLUME C:\data
RUN Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices' -Name 'G:' -Value "??\C:\data" -Type String;

Steps to reproduce the behavior

  1. docker run -ti --name docker-bld3 -v C:\dckvol:c:/data -w /data node:10.16.3-winsevercore1803 powershell
  2. check source code to /data and build inside it.

CH03 - Manifest Unknown

When trying to run:

docker container run -d -P dockeronwindows/ch03-nerd-dinner-web:2e-v2 from the ch03-nerd-dinner-web directory, the issue occurs:

PS C:\DockerStudy\ch03\ch03-nerd-dinner-web> docker container run -d -P dockeronwindows/ch03-nerd-dinner-web:2e-v2
Unable to find image 'dockeronwindows/ch03-nerd-dinner-web:2e-v2' locally
C:\Program Files\Docker\docker.exe: Error response from daemon: manifest for dockeronwindows/ch03-nerd-dinner-web:2e-v2 not found: manifest unknown: manifest unknown.
See 'C:\Program Files\Docker\docker.exe run --help'._

System can not find path

Hello,

When i perform the run command as below i get this error.

PS C:\Users\Administrator> docker container run dockeronwindows/ch01-whale:2e
Unable to find image 'dockeronwindows/ch01-whale:2e' locally
2e: Pulling from dockeronwindows/ch01-whale
6a5e981230da: Pulling fs layer
7fe5fc4b6b6d: Pulling fs layer
2a921185b5ca: Pulling fs layer
ce55179130f6: Waiting
docker: open C:\ProgramData\docker\tmp\GetImageBlob786153451: Het systeem kan het opgegeven pad niet vinden.
See 'docker run --help'.

I am running a VM Windows 2019 (1809)

Client: Mirantis Container Runtime
 Version:           20.10.9
 API version:       1.41
 Go version:        go1.16.12m2
 Git commit:        591094d
 Built:             12/21/2021 21:34:30
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Mirantis Container Runtime
 Engine:
  Version:          20.10.9
  API version:      1.41 (minimum version 1.24)
  Go version:       go1.16.12m2
  Git commit:       9b96ce992b
  Built:            12/21/2021 21:33:06
  OS/Arch:          windows/amd64
  Experimental:     false

btw: In the whale readme the run command states ddocker and not docker.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.