Unable to mount volume for /var/lib/mysql in centos6 image

I have tried to mount volume for /var/lib/mysql folder on centos6 image which is installed mysql. but it does automatically mount that particular folder.

ex : docker run --name test -v /database:/var/lib/mysql -d centos:mysql

but it automatically mount on /var/lib/docker/vfs/dir/c6542b0db1c1b606a786fa69a1aa27490494f1b52a18c4298a4c979cb461be8a/ folder.

how to mount /var/lib/mysql folder on /database instead of /var/lib/docker/vfs/dir ??

Your example means you’re trying to mount the host computer’s /database directory into the /var/lib/mysql into the container (which is actually a directory in /var/lib/docker/vfs...

Yes… But it does not mount.

What may be the reason?

can you give me more info - docker version and docker info output, the output of ls -lah /database from the host, and ls -la /var/lib inside the container?

docker version

Client version: 1.4.1
Client API version: 1.16
Go version (client): go1.3.3
Git commit (client): 5bc2ff8/1.4.1
OS/Arch (client): linux/amd64
Server version: 1.4.1
Server API version: 1.16
Go version (server): go1.3.3
Git commit (server): 5bc2ff8/1.4.1

docker info

Containers: 6
Images: 167
Storage Driver: devicemapper
Pool Name: docker-253:0-393465-pool
Pool Blocksize: 65.54 kB
Data file: /var/lib/docker/devicemapper/devicemapper/data
Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
Data Space Used: 6.459 GB
Data Space Total: 107.4 GB
Metadata Space Used: 9.794 MB
Metadata Space Total: 2.147 GB
Library Version: 1.02.89-RHEL6 (2014-09-01)
Execution Driver: native-0.2
Kernel Version: 2.6.32-504.8.1.el6.x86_64
Operating System:
CPUs: 2
Total Memory: 2.808 GiB
Name: 192.168.1.5.static.hvvc.us
ID: TTTA:UQAQ:OP5F:UHIF:NUSF:N4GK:IHUY:PYIW:UZTU:4BRN:F4DL:ICMX
Username:
Registry: [https://index.docker.io/v1/]

]# ls -lah /database
total 8.0K
drwxr-xr-x. 2 root root 4.0K Feb 19 00:52 .
dr-xr-xr-x. 33 root root 4.0K Feb 19 00:52 …

[root@f99e80736bb9 /]# ls -la /var/lib
total 44
drwxr-xr-x. 10 root root 4096 Feb 14 06:37 .
drwxr-xr-x. 17 root root 4096 Jan 29 08:25 …
drwxr-xr-x. 2 root root 4096 Jan 29 08:26 alternatives
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games
drwxr-xr-x. 2 root root 4096 Sep 23 2011 misc
drwxr-xr-x. 5 mysql mysql 4096 Feb 14 10:13 mysql
-rw-------. 1 root root 4096 Jan 29 08:26 random-seed
drwxr-xr-x. 2 root root 4096 Jan 29 08:27 rpm
drwxr-xr-x. 4 root root 4096 Jan 29 08:26 stateless
drwxr-xr-x. 3 root root 4096 Jan 29 08:26 udev
drwxr-xr-x. 6 root root 4096 Feb 14 06:37 yum

it suddenly occurs to me - are you using selinux (or have it on?)