compose icon indicating copy to clipboard operation
compose copied to clipboard

Local Env Variable Syntax error, Persisit %Userprofile% folder volume

Open abelkbil opened this issue 3 years ago • 8 comments

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 $.

abelkbil avatar Feb 23 '22 18:02 abelkbil

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

abelkbil avatar Feb 24 '22 09:02 abelkbil

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 avatar Feb 24 '22 09:02 ndeloof

@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

abelkbil avatar Feb 25 '22 05:02 abelkbil

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)

ndeloof avatar Feb 25 '22 07:02 ndeloof

Also, please check you can run this container successfully with a classic docker run -v ... command, and this is a compose issue.

ndeloof avatar Feb 25 '22 07:02 ndeloof

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"]

abelkbil avatar Mar 11 '22 04:03 abelkbil

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

victorigualada avatar Mar 15 '22 11:03 victorigualada

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.

stale[bot] avatar Sep 21 '22 10:09 stale[bot]

Closing inactive issue

ndeloof avatar May 03 '23 15:05 ndeloof