iredmail-docker icon indicating copy to clipboard operation
iredmail-docker copied to clipboard

Configuration for persistent data of mysql

Open kopax opened this issue 9 years ago • 3 comments

conf : Docker version 1.8.2, build 0a8c2e3 Linux prod-01 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u4 (2015-09-19) x86_64 GNU/Linux

I am trying to install `cema-sp/iredmail-docker with this docker-compose.yml file :

iredmail:
  image: cema/iredmail:example
  hostname: mail
  domainname: ilovesports.com
  privileged: true
  volumes:
    - /srv/docker/iredmail/backups:/backups:rw
    - /srv/docker/iredmail/mysql:/var/lib/mysql:rw
  ports: 
    - "25:25"
    - "80:80" 
    - "587:587"
    - "110:110"
    - "143:143"
    - "389:389"
    - "443:443"
    - "995:995"
    - "993:993"
    - "636:636"

When running the container got stuck on :

[~/iredmail]: docker-compose stop && docker-compose up
Stopping iredmail_iredmail_1... done
Starting iredmail_iredmail_1...
Attaching to iredmail_iredmail_1

Container start but mysql service is stopped, test from inside the container :

root@mail:/var/lib# service mysql status
MySQL is stopped..
root@mail:/var/lib# service mysql start
Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!

Container logs only has Attaching to iredmail_iredmail_1

Content of folder /srv/docker on host is owned by root:docker

Content of folder /srv/docker/iredmail/mysql is empty

I have tried without mounting /var/lib/mysql and it worked, do you guy have the same issue ?

Last question, do I have any other volumes to mount so it won't lose any data on restart ?

kopax avatar Oct 05 '15 22:10 kopax

It looks like a bug, any Idea where to fix this ?

kopax avatar Oct 06 '15 00:10 kopax

So I figure it out, about mysql.

Because the Docker image is builded before, when we try to mount a drive like /srv/docker/iredmail/mysql:/var/lib/mysql, the folder /var/lib/mysql come empty because the content of this folder is created only for the first run, and during the build it doesn't have the acces right to write on it.

I had to copy the first launch content of the directory, then rebuild the image again after placing the copy into /srv/docker/iredmail/mysql and add the following at the end of the Dockerfile :

RUN chown vmail:vmail /var/vmail \
    && chmod 755 /var/vmail \
    && chown mysql:mysql /var/lib/mysql \
    && chmod 755 /var/lib/mysql

On next image build, the mysql directory should be OK, but you will have the exact same problem for the /etc/apache2 and /etc/sogo/ directory, so you'll have to repeat the operation to get the configuration directory into into a mounted volume, I am trying this right now

Edit : Ok so I still can't make it work, on host machine , mysql directory as this access right

drwxr-xr-x 9 systemd-bus-proxy systemd-timesync 4096 Oct  6 13:03 mysq

What is systemd-bus-proxy systemd-timesync ?

I can run mysql container through the bash but it says right after login that debian-sys-maintain is not allowed to login

Mysql is running but I can't stop or restart the service.

kopax avatar Oct 06 '15 10:10 kopax

Unfortunately this docker image is far from being truly persistent and docker-way.

To improve it one should use separate DB container w/ or w/o mounted volume/data-container for persistence and start all services inside container with startup script, not Ubuntu init.

I use this image "as is" and never remove container (start/stop is ok). For backing up DB you can use/schedule "docker cp" command and save DB directory to archive, but I think it is better to use mysqldump or similar tool for PostgreSQL.

cema-sp avatar Oct 14 '15 12:10 cema-sp