compose
compose copied to clipboard
Local Env Variable Syntax error, Persisit %Userprofile% folder volume
Hi all, 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: ngt-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/ngtcert.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 $.
Error response from daemon: mount denied: the source path "\Users\INaBJOJ1\source:C:\Users\INaBJOJ1\source:rw" too many colons
Trying to find how to use wslpath style
environment variable interpolation uses bash style: ${USERPROFILE}
(no env:
prefix)
is this for a Windows container (not Linux container on Docker Desktop Windows)?
Which version of docker compose are you using?
Can you run this container successfully with a classic docker run ...
command ?
@ndeloof yes i have updated as below and i get colon error, mentioned above.
volumes:
- ./devops/https/ngtcert.pfx:/https/aspnetapp.pfx:ro
- "${USERPROFILE}/source/:${USERPROFILE}/source/"
Error
invalid interpolation format for services.directoryservice.volumes.[]: "${Env:USERPROFILE}\\source:${Env:USERPROFILE}\\source". You may need to escape any $ with another $.
I am trying to generate a windows image. and use compose version 3.4
I'm asking about docker-compose --version
you use, version: 3.4
actually isn't relevant (and can be fully removed if you use a recent compose release)
Also, please check you can run this container successfully with a classic docker run -v ...
command, and this is a compose issue.
Docker Compose version v2.2.3.
I have modified my docker file as below. Stil now not able to resolve it.
# escape=`
FROM mcr.microsoft.com/dotnet/aspnet:6.0
COPY . App/
WORKDIR /App
EXPOSE 44309
VOLUME ${USERPROFILE}\source\
RUN echo ${USERPROFILE}\source\
# RUN dir c:\
ENV ASPNETCORE_ENVIRONMENT="Development"
ENV ASPNETCORE_URLS="https://+:44309;"
ENTRYPOINT ["dotnet", "Service.dll"]
I was facing the same problem after a clean reinstall of the OS. The problem was that docker-compose
wasn't using the last version (1.29) but an old one (1.17) which was causing a lot of errors.
Run docker-compose version
and check that you have the latest version. If not, just install it: https://docs.docker.com/compose/install/#install-compose
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Closing inactive issue