1

I want to run a MediaWiki inside a Docker container. I followed tutorial here, using official mediawiki image. I want to use sqlite instead of MySQL, to have less hassle with separate containers and its files. I've run the image, installed wiki and copied database and other directories from the container to local dir:

$ tree -d -L 2
.
└── Social
    ├── config
    ├── data
    ├── extensions
    └── images

Then I killed and removed docker image and run it again with:

docker run --name social-mediawiki -p 8080:80 \
    -v ~/Mediawiki/Social/config/LocalSettings.php:/var/www/html/LocalSettings.php \
    -v ~/Mediawiki/Social/images:/var/www/html/images \
    -v ~/Mediawiki/Social/extensions:/var/www/html/extensions \
    -v ~/Mediawiki/Social/data:/var/www/data \
    -d mediawiki

Unfortunately, it doesn't work as http://localhost:8080/index.php/Main_Page page explodes with following exception

[847547d534f8a6acfbb81a43] /index.php/Main_Page Wikimedia\Rdbms\DBTransactionStateError from line 1312 of /var/www/html/includes/libs/rdbms/database/Database.php: Cannot execute query from MediaWiki\Storage\SqlBlobStore::fetchBlob while transaction status is ERROR.

Backtrace:

#0 /var/www/html/includes/libs/rdbms/database/Database.php(1095): Wikimedia\Rdbms\Database->assertTransactionStatus(string, string)
#1 /var/www/html/includes/libs/rdbms/database/Database.php(1653): Wikimedia\Rdbms\Database->query(string, string)
#2 /var/www/html/includes/libs/rdbms/database/Database.php(1730): Wikimedia\Rdbms\Database->select(string, array, array, string, array, array)
#3 /var/www/html/includes/Storage/SqlBlobStore.php(329): Wikimedia\Rdbms\Database->selectRow(string, array, array, string, array)
#4 /var/www/html/includes/Storage/SqlBlobStore.php(277): MediaWiki\Storage\SqlBlobStore->fetchBlob(string, integer)
#5 /var/www/html/includes/libs/objectcache/WANObjectCache.php(1240): MediaWiki\Storage\SqlBlobStore->MediaWiki\Storage\{closure}(boolean, integer, array, NULL)
#6 /var/www/html/includes/libs/objectcache/WANObjectCache.php(1114): WANObjectCache->doGetWithSetCallback(string, integer, Closure, array)
#7 /var/www/html/includes/Storage/SqlBlobStore.php(279): WANObjectCache->getWithSetCallback(string, integer, Closure, array)
#8 /var/www/html/includes/Storage/RevisionStore.php(921): MediaWiki\Storage\SqlBlobStore->getBlob(string, integer)
#9 /var/www/html/includes/Storage/RevisionStore.php(865): MediaWiki\Storage\RevisionStore->loadSlotContent(MediaWiki\Storage\SlotRecord, NULL, NULL, NULL, integer)
#10 [internal function]: MediaWiki\Storage\RevisionStore->MediaWiki\Storage\{closure}(MediaWiki\Storage\SlotRecord)
#11 /var/www/html/includes/Storage/SlotRecord.php(308): call_user_func(Closure, MediaWiki\Storage\SlotRecord)
#12 /var/www/html/includes/Storage/RevisionRecord.php(173): MediaWiki\Storage\SlotRecord->getContent()
#13 /var/www/html/includes/Revision.php(937): MediaWiki\Storage\RevisionRecord->getContent(string, integer, User)
#14 /var/www/html/includes/page/Article.php(368): Revision->getContent(integer, User)
#15 /var/www/html/includes/page/Article.php(562): Article->fetchContentObject()
#16 /var/www/html/includes/actions/ViewAction.php(68): Article->view()
#17 /var/www/html/includes/MediaWiki.php(500): ViewAction->show()
#18 /var/www/html/includes/MediaWiki.php(294): MediaWiki->performAction(Article, Title)
#19 /var/www/html/includes/MediaWiki.php(861): MediaWiki->performRequest()
#20 /var/www/html/includes/MediaWiki.php(524): MediaWiki->main()
#21 /var/www/html/index.php(42): MediaWiki->run()
#22 {main}

Sqlite file itself looks fine:

$ sudo sqlite3 my_wiki.sqlite 
sqlite> PRAGMA integrity_check;
ok
sqlite> select * from page;
1|0|Main_Page||0|1|0.468882297482|20181231020833||1|735|wikitext|
sqlite> 

Dumping database into a new file (ad described here) didn't help. No change was made to LocalSettings.php, with except of debug information:

$wgShowExceptionDetails = true;
$wgShowDBErrorBacktrace = true;
$wgShowSQLErrors = true;

How can I make this work?

Presto
  • 219
  • 1
  • 7

1 Answers1

2

Found the problem. After examining log file in container with followed settings in LocalSettings.php

$wgShowExceptionDetails = true;
$wgShowDBErrorBacktrace = true;
$wgShowSQLErrors = true;
$wgDebugDumpSql = true;
$wgDebugDBTransactions = true;
$wgDebugLogFile = '/tmp/log';

I discovered a lot of write access errors:

[DBQuery] SQL ERROR: attempt to write a readonly database

As it turned out, when I mounted sqlite database data, it has following permissions set:

# cd /var/www
# ls -l
total 8
drwxr-xr-x  3 root     root     4096 Dec 31 03:27 data
drwxrwxrwx 15 www-data www-data 4096 Dec 31 03:30 html

The user and group of dir and its content should be www-data too. After fixing it with:

# chown -R www-data:www-data /var/www/data

Now everything works as expected.

Presto
  • 219
  • 1
  • 7