2

I have this app trying to orchestrate using docker + fig which works great for the first day of trying. It uses a data container where I want to persist my database files and a redis + mysql container(s) used by the app.

Once booted up the mysql container looks inside /var/lib/mysql for data files and, if none found, it creates the default sb which I can then populate and the files are created and also persisted in my data volume.

While I'm learning fig I had to do a fig rm --force mysql which deleted my mysql container. I did this without fear knowing that my data is safe on the data container. Running a ls on my host shows the mysql files still intact.

The problem occurs when I run fig up again which creates the mysql container again. Even though I have the same volumes shared and my old mysql files are still present this new container creates a new database as if the volume shared was empty. This only occurs if I rm the container and not if I close fig and bring it back up.

Here's my fig file if it helps:

data: image: ubuntu:12.04 volumes: - /data/mysql:/var/lib/mysql redis: image: redis:latest mysql: image: mysql:latest ports: - 3306 environment: MYSQL_DATABASE: ***** MYSQL_ROOT_PASSWORD: ***** volumes_from: - data web: build: . dns: 8.8.8.8 command: python manage.py runserver 0.0.0.0:8000 environment: - DEBUG=True - PYTHONUNBUFFERED=1 volumes: - .:/code ports: - "8000:8000" links: - data - mysql - redis

Any ideas why the new mysql container won't use the existing files.?

Romeo Mihalcea
  • 9,714
  • 12
  • 50
  • 102

2 Answers2

0

I have not used fig but will be looking into it as the simplistic syntax in your post looks pretty great. Every day I spend a couple more hours expanding my knowledge about Docker and rewire my brain as to what is possible. For about 3 weeks now I have been running a stateless data container for my MySQL instances. This has been working great with no issues.

If the content inside /var/lib/mysql does not exist when the container starts, then a script installs the needed database files. The script checks to see if the initial database files exist not just the /var/lib/mysql path.

if [[ ! -f $VOLUME_HOME/ibdata1 ]]; then
    echo "=> An empty or uninitialized MySQL volume is detected in $VOLUME_HOME"
    echo "=> Installing MySQL ..."

else
    echo "=> Using an existing volume of MySQL"
fi

Here is a direct link to a MySQL repo I am continuing to enhance

gegere
  • 69
  • 5
  • The files exist when mysql container boots up because docker mounts the volume first which has the required files. I even tried with killing all containers and then firing `fig up` again and it finds the files. Only when I rm the mysql container it does that. I would assume a permission error but I can't find any error relating to that... – Romeo Mihalcea Dec 24 '14 at 08:59
0

This seems to be a bug, see this related question which has links to relevant fig/docker issues: https://stackoverflow.com/a/27562669/204706

Apparently the situation is improved with docker 1.4.1, so you should try using that version if you aren't already.

Community
  • 1
  • 1
jeverling
  • 2,004
  • 1
  • 20
  • 21
  • Switched over from fig to pure vagrant because of that bug which makes the whole setup very unreliable. I am using 1.4.1 by the way. – Romeo Mihalcea Jan 06 '15 at 15:52