New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker container fails on first startup due to inability to connect to Sqlite database #19156
Comments
Looks like you're either missing or forgot to include the database specification in your docker-compose snippet. environment:
DB_CLIENT: 'sqlite3'
DB_FILENAME: '/directus/database/data.db' Also double check the folder permissions of |
Facing the same issue and this does not work either |
Thats not a lot to go on? Are you using the same config with missing required database settings? Did you check the permissions? |
I had this exact problem, and the problem turned out to be the permissions on the two folders; just using: version: '3'
services:
directus:
image: directus/directus:latest
ports:
- 8055:8055
volumes:
- ./database:/directus/database
- ./uploads:/directus/uploads
environment:
KEY: '2b93bbfa-6650-459f-b6e1-1016d96e1b25'
SECRET: '8053fec6-1e3d-4a6c-8f65-4e7291308f5a'
ADMIN_EMAIL: 'admin@example.com'
ADMIN_PASSWORD: 'd1r3ctu5'
DB_CLIENT: 'sqlite3'
DB_FILENAME: '/directus/database/data.db'
WEBSOCKETS_ENABLED: true Caused an error on first request:
The two directories had been created by the root user inside the container:
Removing them and recreating them as my current user fixed the problem and allowed startup to proceed; I haven't had this issue with other folder-using containers before, so maybe this comes down to which users the container runs as internally. |
This is the config the docs give us. I have the same issue. The docs where the config is shown (https://docs.directus.io/self-hosted/quickstart.html) should probably suggest you create the 2 volume folders yourself. |
What environment are you running this on @robclancy / @jakebailey? It shouldn't matter (that's kinda the point of Docker), but just to be sure. On my end (on macOS Ventura 13.4.1), things seem to work exactly as expected: Created an empty folder, copy pasted the linked docker-compose.yml file version: '3'
services:
directus:
image: directus/directus:latest
ports:
- 8055:8055
volumes:
- ./database:/directus/database
- ./uploads:/directus/uploads
environment:
KEY: 'replace-with-random-value'
SECRET: 'replace-with-random-value'
ADMIN_EMAIL: 'admin@example.com'
ADMIN_PASSWORD: 'd1r3ctu5'
DB_CLIENT: 'sqlite3'
DB_FILENAME: '/directus/database/data.db'
WEBSOCKETS_ENABLED: true ran docker compose output
I was able to browse/use the app as normal, and based on the file system, it looks like the volumes are syncing / behaving as intended as well 🤔 |
I was originally using Docker within WSL (which is effectively a VM), but I also just tested on my native Arch Linux machine; doing exactly what you wrote above fails with the sqlite error. If you've only been testing on macOS and not on Linux, it's possible that there's some weirdness coming from the mixed-OS setup (maybe due to the way FS accesses are proxied, or some differing mapping of UIDs between the two). |
Arch btw. |
Yeah that's what I'm starting to think too 🤔 @br41nslug can you give it another shot on your end with this exact setup under WSL? |
Just note that if you're on Windows using Docker Desktop, IIRC that's a totally different thing than running the docker daemon within WSL itself; the former has its own special daemon that can run Linux and Windows containers, while the latter is just like installing docker straight onto an Ubuntu VM and running there. (I think most people seem to use the former, but I prefer the latter as I'm much more used to using docker on actual Linux machines.) |
Great great point, which could also explain the difference as one would be running with special windows sauce, whereas the latter would be "pure" linux (which would be more similar to Arch) |
This is reproducable on most linux os's using a default docker installation. The problem seems to be that Docker by default installs the deamon as root which will then create the non-existing Coincedentally i reproduced this a couple days ago (but had lost track of this ticket 😅) screengrab.mp4 |
One thing I see commonly is container images which accept UID/GID via I am not an expert, though. Honestly, I'm a little confused from the perspective that I regularly use the postgres image and point it to a directory, and don't have this problem. What is the difference between the two setups such that directus' image fails? |
For security reasons, the I'm not sure whether there's much we can do, except for adding something like this to the documentation: #6480 (comment) Another idea: We could test if the problem can be solved on the affected platforms by adding the explicit |
@paescuj Another thing that might be worth trying is creating the database folder within the dockerfile and set the permissions appropriately before Directus runs? Line 27 in 3012348
this is creating the folder as Lines 35 to 37 in 3012348
It actually seems like there's a long thread on the (it's still beyond me why this just works out of the box on some environments, but not others, but 🤷🏻 ) |
Cc @wrynegade who might have some ideas |
jakebailey does have a point i've never had this issue either with a postgres docker which goes through effectively the same process of creating a folder and populating it 🤔 That does make me think this is something we should be able to resolve with our image |
What help is needed moving this forward? Fresh pulls of the container are still failing. |
Just took a look at the postgres Dockerfile and they have a section explicitly for setting user/group IDs, see: Need to take a look 👀 |
same problem on Fedora38 on empty dir
|
hacky fix by creating /uploads and /database manually before running docker compose up
|
doesn't work for me, same issue. I'm on Ubuntu 23.10 x64 |
WHAT WORKED FOR ME!
|
Heyo! We have done research into this and this is primarily a docker and docker-compose issue rather than a Directus issue so we will not be continuing investigating/fixing at this time. After diving in this appears to be docker/docker-compose not properly handling permissions for volumes, there are workarounds but there is no straight forward fix. If you are experiencing this issue, you should verify and fix the permissions on the directory you are using with your volume to make sure it aligns. If the scope of this issue grows and this becomes a widespread issue we will of course reopen it and dig back into it 👍 ! |
Describe the Bug
I am attempting to setup Directus using the docker compose example provided in the Directus documentation. When the container is starting up, it immediately fails. I have included the container logs below. I am not sure how to proceed and would appreciate your feedback. Thank you.
Container Logs
To Reproduce
docker compose up -d
.Docker Compose
Directus Version
v10.4.3
Hosting Strategy
Self-Hosted (Docker Image)
The text was updated successfully, but these errors were encountered: