Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose volume not mounted

My docker-compose.yml is:

version: '2'
services:
  joomla:
    image: joomla
    links:
      - joomladb:mysql
    volumes:
      - "./www:/var/www/html"
    ports:
      - 9010:80
    environment:
      MYSQL_PORT_3306_TCP: 3306
      JOOMLA_DB_HOST: joomladb
      JOOMLA_DB_PASSWORD: "example"
      JOOMLA_DB_USER: "root"
      JOOMLA_DB_NAME: "joomla"

  joomladb:
    image: mysql:5.6
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: "example"
      MYSQL_DATABASE: "joomla"
    volumes:
      - "./db:/var/lib/mysql"
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
     - 9011:80
    environment:
      MYSQL_ROOT_PASSWORD: "example"
      MYSQL_DATABASE: "joomla"
    container_name: phpmyadmin

/var/www/html is mounted in the host (dir www) with all the joomla files. However host directory ./db is not even created.

However if I get into db container, directory is not empty:

root@docker1:/home/juanda/soplaelcierzo# docker exec -t -i 959 /bin/bash
root@95926c23f49a:/# cd /var/lib/mysql/
root@95926c23f49a:/var/lib/mysql# ls
auto.cnf  ib_logfile0  ib_logfile1  ibdata1  joomla  joomladb  mysql  performance_schema
like image 963
user2670996 Avatar asked Sep 12 '16 04:09

user2670996


2 Answers

I was getting a warning I didn't see:

WARNING: Service "joomladb" is using volume "/var/lib/mysql" from the previous container. Host mapping "/home/juanda/soplaelcierzo/db" has no effect. Remove the existing containers (with docker-compose rm joomladb) to use the host volume mapping.

like image 136
user2670996 Avatar answered Oct 28 '22 14:10

user2670996


this issue could when e.g. there are 2 similar folders with the same project. So when you run docker-composer in first folder it bind its local folder "./db" to container volume. If after that try to run in another folder it try to bind another folder to the same container path. So advice above about

docker-compose rm joomladb

should help

like image 31
Rinat Avatar answered Oct 28 '22 16:10

Rinat