Reputation: 546
I have a .net + React.js application and I am trying to conatinerize it. I have succesfully mounted my sqlite database in docker container by using following docker-compose file:
version: '3.4'
services:
webapp:
image: ${DOCKER_REGISTRY-}webapp
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:80"
volumes:
- "./Database:/Database"
However when I am running the container the error No such table
occurs. I have installed sqlite3 in my container and I run sqlite3 and the tables with records indeed exist:
# cd Database
# sqlite3 MyDatabase.db
SQLite version 3.34.1 2021-01-20 14:10:07
Enter ".help" for usage hints.
sqlite> .tables
Table1 Table2
Table3 __EFMigrationsHistory
sqlite>
.Net application is in directory /app and database is in directory /Database and both of them are on the same level. I really have no idea what might be a problem.
Upvotes: 4
Views: 1807
Reputation: 546
I have changed my connection string from:
optionsBuilder.UseSqlite("Datasource=..\\Database\\FinanceWebAppDatabase.db");
to:
optionsBuilder.UseSqlite(@"Datasource=../Database/FinanceWebAppDatabase.db");
Apparently in the first container was looking for a file named '.\Database\FinanceWebAppDatabase.db'
Upvotes: 4