I am searching on how to persist user profile folder in volume mounting
I have folder C:\Users\ABEL\source\repos which needs to be persisted for a windows container. The username should be from the host. It is unknown.
Below is my docker-compose file, The volume section is not correct. Any comments will be helpful. Thanks in advance
version: '3.4'
services:
directoryservice:
image: abc-directoryservice:latest
build: .
ports:
- "44309:44309"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:44309;
- ASPNETCORE_Kestrel__Certificates__Default__Password=welcome123#
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
volumes:
- ./devops/https/abccert.pfx:/https/aspnetapp.pfx:ro
# - "$env:USERPROFILE/source:$env:USERPROFILE/source"
- ${Env:USERPROFILE}\source:${Env:USERPROFILE}\source
I get below error
invalid interpolation format for services.directoryservice.volumes.[]: "${Env:USERPROFILE}\\source:${Env:USERPROFILE}\\source". You may need to escape any $ with another $.
The $env:USERPROFILE
/ ${env:USERPROFILE}
syntax is specific to PowerShell.
Judging by the docs, docker-compose
uses its own syntax: $USERPROFILE
/ ${USERPROFILE}
You report a follow-up problem, namely that the Windows-style path stored in $USERPROFILE
(%USERPROFILE%
) (e.g. C:\Users\jdoe\source
) isn't converted to a Unix-style path (e.g. c/Users/jdoe/source
)
This answer suggests that you must set environment variable COMPOSE_CONVERT_WINDOWS_PATHS
to 1
, before running your docker-compose
command.
E.g., in a PowerShell session:
$env:COMPOSE_CONVERT_WINDOWS_PATHS=1
Consider adding this statement to your $PROFILE
file so that it takes effect in future PowerShell sessions too.