Доброе утро.
Я работаю с Docker для Windows 19.03.8, сборка afacb8b; работает на Windows Server 2019 (10.0.17763.1039)
, когда я запускаю Docker -Compose up -dV, он говорит что-то вроде:
Creating network "docker_default" with the default driver
Creating docker_python-base_1 ... done
Creating docker_msbuild_1 ... done
, но когда я тогда использую Docker -Compose exe c, он говорит: ERROR: No container found for msbuild_1
другими словами, UP и EXE C не используют одно и то же ( по умолчанию?) имя контейнера.
Аль-Валид Шихадех попросил дополнительную информацию (спасибо вам !!!!). итак ....
мой docker -compose.yml файл:
version: '3.7'
services:
python-base-srv:
build:
context: ./images/python-base
dockerfile: Dockerfile-PythonBase
image: mycompany/builds-win-base-python:3.7.6
volumes:
- ../../..:C:/bldroot
command: powershell -NoExit -NonInteractive
msbuild-srv:
build:
context: ./images/msbuild
dockerfile: Dockerfile-msbuild
image: mycompany/builds-win-msbuild:15.0
volumes:
- ../../..:C:/bldroot
depends_on:
- python-base-srv
command: powershell -NoExit -NonInteractive
Dockerfile-msbuild:
# escape=`
ARG FROM_IMAGE=mycompany/builds-win-base-python
FROM ${FROM_IMAGE} AS build
SHELL [ "powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';" ]
RUN Invoke-WebRequest 'https://aka.ms/vs/15/release/vs_buildtools.exe' -OutFile C:\Downloads\vs_buildtools.exe -UseBasicParsing ; `
Start-Process -FilePath 'C:\Downloads\vs_buildtools.exe' -Wait `
-ArgumentList `
'--quiet', `
'--norestart', `
'--locale en-US', `
'--installPath C:\BuildTools', `
'--nocache', `
'--addProductLang en-US', `
'--add Microsoft.Net.Component.3.5.DeveloperTools', `
'--add Microsoft.Net.Component.4.5.TargetingPack', `
'--add Microsoft.Net.ComponentGroup.4.6.1.DeveloperTools', `
'--add Microsoft.Net.ComponentGroup.4.6.2.DeveloperTools', `
'--add Microsoft.Net.ComponentGroup.TargetingPacks.Common', `
'--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.WinXP' ; `
Remove-Item c:\Downloads\vs_buildtools.exe -Force
RUN $PATH = $env:PATH + ';C:\BuildTools\MSBuild\15.0\Bin' ; `
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $PATH
# Start developer command prompt before running the specified command (from RUN/EXEC commandline)
COPY ["VsDevCmdPowerShell.bat", "C:\\BuildTools\\"]
ENTRYPOINT ["cmd", "/k", "C:\\BuildTools\\VsDevCmdPowerShell.bat"]
Dockerfile-PythonBase:
# escape=`
ARG FROM_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2019
FROM ${FROM_IMAGE} AS python-base
SHELL [ "powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';" ]
RUN `
New-Item -Path C:\Downloads -ItemType Directory ; `
New-Item -Path C:\path -ItemType Directory ; `
`
$PATH = 'C:\path;' + $env:PATH ; `
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $PATH ; `
`
Invoke-WebRequest 'https://www.python.org/ftp/python/3.7.6/python-3.7.6.exe' -OutFile c:\Downloads\python-installer.exe -UseBasicParsing ; `
Start-Process c:\Downloads\python-installer.exe -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1' -Wait ; `
Remove-Item c:\Downloads\python-installer.exe -Force
CMD ["powershell", "-NoExit", "-NoLogo", "cmd", "/c ver", ";", "python", "--version", ";", "nuget", "help | select -First 1", ";"]
Выходные данные:
C:\work\docker> docker-compose up -dV msbuild-srv
Recreating docker_python-base-srv_1 ... done
Recreating docker_msbuild-srv_1 ... done
C:\work\docker> docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------
docker_msbuild-srv_1 cmd /k C:\BuildTools\VsDev ... Exit 0
docker_python-base-srv_1 powershell -NoExit -NonInt ... Exit 0
C:\work\docker> docker logs docker_msbuild-srv_1
Call VsDevCmd.bat to setup environment . . .
C:\>call C:\BuildTools\Common7\Tools\VsDevCmd.bat
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
powershell -NoExit -NonInteractive
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\>
C:\>
C:\work\docker>
Итак - контейнеры не выполняются на этапе компоновки UP, как это должно быть.
docker run -it работает нормально: docker container run -it --name msbuildTesting -v C:/work:C:/bldroot -w c:\bldroot\build mycompany/builds-win-msbuild