4

I am running Sitecore with docker containers and all services are up and running via docker-compose. This project uses TDS. Now I need to expose the CM's website root folder from the running container to my host, so I can configure the TDS projects in VS. But many files are not created when I add the following volume to CM service making CM to stop working. - .\cmwebsite:C:\Sitecore\website

CM docker file:

# escape=`
ARG BASE_IMAGE=mcr.microsoft.com/dotnet/framework/aspnet:4.7.2-windowsservercore-1803

FROM $BASE_IMAGE

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

COPY .\*.zip .

RUN Expand-Archive -Path 'C:\Sitecore*.zip' -DestinationPath 'C:'; `
    Remove-Item 'C:\Sitecore*.zip' -Force; `
    New-Item -Path 'C:\Sitecore' -Type Directory | Out-Null; `
    Move-Item -Path 'C:\Sitecore *\Data' -Destination 'C:\Sitecore'; `
    Move-Item -Path 'C:\Sitecore *\Website' -Destination 'C:\Sitecore'; `
    Remove-Item -Path 'C:\Sitecore\Data\logs' -Recurse -Force; `
    Remove-Item -Path 'C:\Sitecore *rev*' -Recurse -Force;

COPY Sitecore /Sitecore
COPY license.xml /Sitecore/Data

RUN Import-Module WebAdministration; `
    Set-ItemProperty -Path 'IIS:\Sites\Default Web Site' -Name 'physicalPath' -Value 'C:\Sitecore\Website'; `
    Set-ItemProperty -Path 'IIS:\AppPools\DefaultAppPool' -Name 'enable32BitAppOnWin64' -Value 'True'; `
    Set-Itemproperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord; `
    setx /M PATH $($env:PATH + ';C:\Sitecore\Scripts');

And here is docker-compose.yml

version: '2.4'

services:

  sql:
    image: sitecore-sqldev
    volumes:
      - .\sovereign\sitecore-sqldev\dbs:C:\Data
    mem_limit: 2GB
    ports:
      - "44010:1433"

  solr:
    image: solr:4.10
    ports: 
      - "8990:8983"

  cm:
    image: sitecore-cm:8.1.160519-windowsservercore-1803
    volumes:
      - .\cmwebsite:C:\Sitecore\website
      -  C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Remote Debugger:C:\remote_debugger:ro
      - .\data\cm:C:\Sitecore\Data\logs
      - .\src:c:\inetpub\wwwroot
    ports:
      - "44001:80"
    links:
      - sql
      - solr
    entrypoint: cmd /c "start /B powershell C:/sitecore/scripts/Watch-Directory.ps1 C:/inetpub/wwwroot C:\Sitecore\website & C:\\remote_debugger\\x64\\msvsmon.exe /noauth /anyuser /silent /nostatus /noclrwarn /nosecuritywarn /nofirewallwarn /nowowwarn /timeout:2147483646"

  cd:
    image: sitecore-cd:8.1.160519-windowsservercore-1803
    volumes:
      -  C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Remote Debugger:C:\remote_debugger:ro
      - .\data\cd:C:\Sitecore\Data\logs
      - .\src:c:\inetpub\wwwroot
    ports:
      - "44002:80"
    links:
      - sql
      - solr
    entrypoint: cmd /c "start /B powershell C:/sitecore/scripts/Watch-Directory.ps1 C:/inetpub/wwwroot C:\Sitecore\website & C:\\remote_debugger\\x64\\msvsmon.exe /noauth /anyuser /silent /nostatus /noclrwarn /nosecuritywarn /nofirewallwarn /nowowwarn /timeout:2147483646"

Am I missing something? Thanks.

1 Answer 1

7

You cannot mount a volume to an existing directory inside your container on Windows Docker. You need to map up a new directory and then use some means of moving the files to the destination you ultimately want.

This is what Watch-Directory takes care of in your entrypoint:.

Source: can not mount volume if the directory in container is not empty

For the record; you can do this when Docker is in Linux mode. Just not in Windows mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.