Reputation: 303
I have two paths. One to take templates from and one to generate documents in. Deploying this on Docker works fine (the App starts, works and gives no warnings), bind mount creates these 2 directories on my local machine, but doesn't seem to use them, or even create them? on the container.
Here is what I tried:
1) Specified paths in AppSettings.json (this is my configuration without Docker, it will be overridden below in docker-compose file)
"RootDirectoryForDocuments": {
"DocumentsRoot": "TestDocumentsDir",
"TemplatesRoot": "TestTemplatesDir"
}
2) Created Docker Compose File. Here first I'm giving the paths as environment variables and then trying to make the container use them in volumes section:
version: "3.7"
services:
hraapi:
build: ../Hra.Api
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ENV_RootDirectoryForDocuments_DocumentsRoot="/app/GeneratedDocs"
- ENV_RootDirectoryForDocuments_TemplatesRoot="/app/Templates"
image: user/hra.api:v1.0
container_name: hra.api
ports:
- "5000:80"
depends_on:
- hradb
volumes:
- C:/Users/User/Desktop/GeneratedDocs:/app/GeneratedDocs
- C:/Users/User/Desktop/Templates:/app/Templates
When I run this DockerCompose it automatically creates these 2 Folders on my Desktop. However, I was hoping it would create and use them in the Container as well. I tried a lot to find how ASP.NET Core containers are structured, in order to use an already existing path there but without success.
Upvotes: 1
Views: 1040
Reputation: 72
I'm sorry, I can't comment yet, but here might be solution to your "container hierarchy" problem:
Do this docker works on your local machine? You can log into the working docker container using the id of the container and check exactly what's happening inside on the filesystem. First, get the docker id:
#> docker ps
Then, using the id (it will look like: ka7859adgfa59)
#> docker exec -it ka7859adgfa59 /bin/bash
you can get inside the container with bash shell.
The "volumes:" part uses the Short Syntax, which should create those folders inside if they are not there already SHORT SYNTAX
Upvotes: 1