Hi,
I am new to OpenGRC and tried to get the docker image in Windows (with Docker for Desktop) running. I ran into several issues:
#1 when running the docker container, I got the error "exec /var/www/html/docker-entrypoint.sh: no such file or directory". This seemed to be due to windows-like file ending when cloning the git repository. there seemed to be a way with "git config --global core.autocrlf" to do this, but in my cases it seemed insuffcient and I completed the thing with using Notepad++ to change the line ending to Unix on docker-entrypoint.sh and rebuilding the image
#2 then I ran into an issue that stated "KeyGenerateCommand.php line 100: file_get_contents(/var/www/html/.env): Failed to open stream: No such file or directory"
when searching for it this seemed to be a standard issue with Laravel / artisan when there is no .env file. There was none in the docker image and any help on .env file and docker images was "well the env is supposed to be passed to docker with --env-file". this was not really working and turned into a whole lot of other problems, as there was no pre-deliverd .env.example or similar file that seemed to match what is exactly in the docker image. the solution was to add the following lines ionto docker-entrypoint.sh (after echo "Starting OpenGRC container..."):
touch .env
echo "APP_KEY=" > .env
the second line was because there was also then an error if left out that said app_key generation failed because there was no such variable in the .env file resulting in a running apache but a 500 error.
#3 after OpenGRC coming up it appeared that nothing could be saved. Also applying "-v opengrc-data:/var/www/html/database" to the docker run command changed nothing. I checked the /var/www/html/database and it seemed that only root can write to it.
so I added to docker-entrpoint.sh after "chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache"
the following line:
"chmod -R 777 /var/www/html/database"
rebuild, re-run
Now, I could save vendors and assets etc
#4 after stopping the container in docker and trying to run it again (with the play button in docker desktop), it seems that it has forgotten it was already used (saying in the log "First run detected - seeding database and creating admin user...") and then laters fails with:
INFO Seeding database.
In Connection.php line 838:
SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: users.email (Connection: sqlite, Database: /var/www/html/database/opengrc.sqlite, SQL: insert into "users" ("email", "name", "password", "password_reset_required", "updated_at", "created_at") values (admin@opengrc.local, admin@opengrc.local, $2y$12$03hxkOGXwabzO5FHJ26NtevDJ6/oBbc.GbHEaUvFLOtidGmuDcRyG, 0, 2026-05-15 20:11:29, 2026-05-15 20:11:29))
In Connection.php line 584:
SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: users.email
I am assuming this is because the persistent already created database is already there and the installer tries to create it.
I have found a solution by editing the docker-entrypoint.sh and include an sqlite check as well:
after
echo "Seed and create admin user only on first run (check if users table is empty)"
USER_COUNT=$(php -r "
\$dsn = 'mysql:host=' . getenv('DB_HOST') . ';port=' . (getenv('DB_PORT') ?: 3306) . ';dbname=' . getenv('DB_DATABASE');
\$pdo = new PDO(\$dsn, getenv('DB_USERNAME'), getenv('DB_PASSWORD'));
echo \$pdo->query('SELECT COUNT(*) FROM users')->fetchColumn();
" 2>/dev/null || echo "0")
insert
if [ "$USER_COUNT" = "0" ]; then
echo "MySQL DB was empty, try again with SQLITE"
USER_COUNT=$(php -r "
\$dsn = 'sqlite:/var/www/html/database/opengrc.sqlite';
\$pdo = new PDO(\$dsn);
echo \$pdo->query('SELECT COUNT(*) FROM users')->fetchColumn();
" 2>/dev/null || echo "0")
echo "USER_COUNT after sqllite was:" $USER_COUNT
fi
#5 However, Now I am facing a new problem with an HTTP 500:
`Illuminate\Encryption\MissingAppKeyException
vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:83
No application encryption key has been specified. `
I found the solution in the app key generation being inside of the inital setup, so in my case the following worked:
search for:
if [ "$USER_COUNT" = "0" ]; then
echo "First run detected - seeding database and creating admin user..."
# Generate APP_KEY if not set
if [ -z "$APP_KEY" ]; then
echo "Generating application key..."
php artisan key:generate --force
fi
replace with (which just puts the key:generate before the first run block)
# Generate APP_KEY if not set
if [ -z "$APP_KEY" ]; then
echo "Generating application key..."
php artisan key:generate --force
fi
if [ "$USER_COUNT" = "0" ]; then
echo "First run detected - seeding database and creating admin user..."
now the docker image runs again with a database that was used earlier after a stop and start.
#6 the documentation states "OpenGRC includes a production-ready Dockerfile [...]", yet the admin password is hardcoded in the docker-entrypoint.sh - wouldn't it be more prudent to ask this from a passed env variable and include it in the doc?
I would like to ask to try the docker image and update the doc esp. for people without much docker experience. big thanks in advance.
Hi,
I am new to OpenGRC and tried to get the docker image in Windows (with Docker for Desktop) running. I ran into several issues:
#1 when running the docker container, I got the error "exec /var/www/html/docker-entrypoint.sh: no such file or directory". This seemed to be due to windows-like file ending when cloning the git repository. there seemed to be a way with "git config --global core.autocrlf" to do this, but in my cases it seemed insuffcient and I completed the thing with using Notepad++ to change the line ending to Unix on docker-entrypoint.sh and rebuilding the image
#2 then I ran into an issue that stated "KeyGenerateCommand.php line 100: file_get_contents(/var/www/html/.env): Failed to open stream: No such file or directory"
when searching for it this seemed to be a standard issue with Laravel / artisan when there is no .env file. There was none in the docker image and any help on .env file and docker images was "well the env is supposed to be passed to docker with --env-file". this was not really working and turned into a whole lot of other problems, as there was no pre-deliverd .env.example or similar file that seemed to match what is exactly in the docker image. the solution was to add the following lines ionto docker-entrypoint.sh (after echo "Starting OpenGRC container..."):
touch .env
echo "APP_KEY=" > .env
the second line was because there was also then an error if left out that said app_key generation failed because there was no such variable in the .env file resulting in a running apache but a 500 error.
#3 after OpenGRC coming up it appeared that nothing could be saved. Also applying "-v opengrc-data:/var/www/html/database" to the docker run command changed nothing. I checked the /var/www/html/database and it seemed that only root can write to it.
so I added to docker-entrpoint.sh after "chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache"
the following line:
"chmod -R 777 /var/www/html/database"
rebuild, re-run
Now, I could save vendors and assets etc
#4 after stopping the container in docker and trying to run it again (with the play button in docker desktop), it seems that it has forgotten it was already used (saying in the log "First run detected - seeding database and creating admin user...") and then laters fails with:
I am assuming this is because the persistent already created database is already there and the installer tries to create it.
I have found a solution by editing the docker-entrypoint.sh and include an sqlite check as well:
after
insert
#5 However, Now I am facing a new problem with an HTTP 500:
`Illuminate\Encryption\MissingAppKeyException
vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:83
No application encryption key has been specified. `
I found the solution in the app key generation being inside of the inital setup, so in my case the following worked:
search for:
replace with (which just puts the key:generate before the first run block)
now the docker image runs again with a database that was used earlier after a stop and start.
#6 the documentation states "OpenGRC includes a production-ready Dockerfile [...]", yet the admin password is hardcoded in the docker-entrypoint.sh - wouldn't it be more prudent to ask this from a passed env variable and include it in the doc?
I would like to ask to try the docker image and update the doc esp. for people without much docker experience. big thanks in advance.