Where does APPDATA get initialized in the default docker-compose.override file
Asked Answered
I

2

9

Below I will show the default docker-compose.override.yml file that was created for me when added orchestration to my ASP.NET application. This is using .NET Core 3.1. I right clicked on the project file -> Add -> Container Orchestrator Support... and the docker-compose project was added to my solution. (Obviously I chose Docker Compose in the options).

I would like to know where the variable APPDATA is being initialized so that I can understand the full path. I understand how the volumes work; I'm simply interested in knowing how and where APPDATA is initialized.

version: '3.4'

services:
  myproject:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=https://+:443;http://+:80
    ports:
      - "80"
      - "443"
    volumes:
      - ${APPDATA}/Microsoft/UserSecrets:C:\Users\ContainerUser\AppData\Roaming\Microsoft\UserSecrets:ro
      - ${APPDATA}/ASP.NET/Https:C:\Users\ContainerUser\AppData\Roaming\ASP.NET\Https:ro
Immaterial answered 13/2, 2020 at 2:13 Comment(0)
D
7

I know this is an old post and you probably figure it out but, APPDATA is variable built in with Windows.

If you open Windows Explorer or Run and paste APPDATA with % before and after you will get path.

appdata-variable-path

Dubonnet answered 1/10, 2020 at 17:43 Comment(1)
It is an old post but I never got the answer and gave up, moving on to other things. I didn't realize this was a Windows path variable and appreciate this response.Immaterial
C
0

It needs to use $APPDATA to point to Windows AppData folder:

docker-compose.yml

version: "3.8"

..

  net_core_service:
    ..
    environment:
      # should be defined Development-env to allow loading user-secrets located on the local computer.
      - ASPNETCORE_ENVIRONMENT=Development
    ..
    volumes:
      # map the dotnet user-secret folder
      - $APPDATA/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
    ..

..

Example for Docker (use %APPDATA%):

docker run ^
  -e ASPNETCORE_ENVIRONMENT=Development ^
  -v %APPDATA%/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro  ^
  company/image:latest
Claudicant answered 3/5, 2021 at 2:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.