Skip to content
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

Configuration for persistent data of mysql #7

Open
kopax opened this issue Oct 5, 2015 · 3 comments
Open

Configuration for persistent data of mysql #7

kopax opened this issue Oct 5, 2015 · 3 comments

Comments

@kopax
Copy link

kopax commented Oct 5, 2015

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 kopax changed the title How to start iredmail-docker Configuration for persistent data of mysql Oct 5, 2015
@kopax
Copy link
Author

kopax commented Oct 6, 2015

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

@kopax
Copy link
Author

kopax commented Oct 6, 2015

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.

@cema-sp
Copy link
Owner

cema-sp commented Oct 14, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants