I have a old blog running on dotclear2 and I wanted to move it on docker for more flexibility. It’s read-only so I can commit the database container and restart it periodically. It can improve greatly the security of my whole system.

description

I created a directory /docker/dotclear containing the following files: * config.php: dotclear original configuration file. * createuser.sql dotclear2.sql grant.sql

The first step is to dump the current database content.

mysqldump --databases dotclear2 >dotclear2.sql

mariadb container

We will use the mariadb official image.

docker pull mariadb

mariadb sql scripts

The container is built to execute all sql scripts in the directory /docker-entrypoint-initdb.d. To automate the setup, I used the following scripts:

  • createuser.sql:
    Create a user named dotadmin with the same password(update to match your settings).
CREATE USER 'dotadmin'@'%' IDENTIFIED BY 'dotadmin';
  • dotclear2.sql: Dump of the dotclear database.

  • grant.sql: give privileges to the user on the dotclear database. Grant all privileges on the dotclear2 database for user dotadmin.

    GRANT ALL PRIVILEGES ON dotclear2.* TO 'dotadmin'@'%';

container launch

The setenv file provide parameters used by the container at startup:

MYSQL_ROOT_PASSWORD="mypassword"
DOTCLEAR_DUMP_DIR="/docker/dotclear"

Let’s start the database container and name it dotdb.

. /docker/dotclear/setenv
docker run --name dotdb -v $DOTCLEAR_DUMP_DIR:/docker-entrypoint-initdb.d -e MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD -d mariadb

We map the host directory /docker/dotclear to /docker-entrypoint-initdb.d.

dotclear container

I use the container from darknao for dotclear

docker pull darknao/dotclear

docker run --name blog --link dotdb:db -p 127.0.0.1:8017:80 -d darknao/dotclear

I made the container listen only on the localhost interface on an unprivileged port. It’s linked to the mariadb container.

The last step is to copy files from the existing dotclear installation. At least copy the dotclear configuration file in the folder inside the container. If needed copy the different media files too.

 docker cp config.php blog:/var/www/html/inc