Closed Hippoom closed 8 years ago
Hello @Hippoom ,
So there was already data in your "$(pwd)/data" directory? If yes, did you try with another empty location to see if it worked?
Personally I never use mysql data like this. I always create data containers, as it's faster and less issues with, well permissions :)
@tonivdv Thanks for the response.
The "$(pwd)/data" is empty and does not even exist before I run the command.
@tonivdv with data containers approach:
$: docker create --name mysqldata -v $(pwd)/data:/var/lib/mysql mysql:5.6 /bin/true
3ab93f92bd8dccc1068680238477bc736f07c8d0b3abc2cd57cdbd5841d384c8
$: docker run -d --volumes-from mysqldata -e MYSQL_ALLOW_EMPTY_PASSWORD=yes mysql:5.6
a5bca62d8ec3b541b03c0509b8de759bfd65f3ad99b8d5d74f5363837bf5ce1d
$: docker logs a5bca62d8ec3b541b03c0509b8de759bfd65f3ad99b8d5d74f5363837bf5ce1d
chown: changing ownership of `/var/lib/mysql/': Operation not permitted
It seems I just cannot bind the host directory....
@Hippoom try to replace -mapall=<your-uid>:<your-gid>
to -maproot=0
in /etc/exports
and restart nfsd by sudo nfsd restart
. Docker-machine reboot is not necessary.
It works fine for me.
Hello @Hippoom ,
Sorry for the delay, seems I missed the notification (thanks to @MurgaNikolay I got a new one :) )
Can you try again following:
docker create --name mysql-data -v /var/lib/mysql mysql:5.6
docker run --name="mysql" --volumes-from mysql-data -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql:5.6
This does work for me:
toni at t-mac in ~/dev/docker
$ docker create --name mysql-data -v /var/lib/mysql mysql:5.6
48449859c4fd7d6a6310d4c9a25aae283a451cfc7cdb8ade8e3067f579c4cdfd
toni at t-mac in ~/dev/docker
$ docker run --name="mysql" --volumes-from mysql-data -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql:5.6
93ef581fdf7753a770e34160c2fbc51a519f05af09371fac6711c0e5b06c0932
toni at t-mac in ~/dev/docker
$ docker logs 93ef581fdf7753a770e34160c2fbc51a519f05af09371fac6711c0e5b06c0932
Running mysql_install_db
2015-10-22 16:50:40 0 [Note] /usr/sbin/mysqld (mysqld 5.6.25) starting as process 24 ...
2015-10-22 16:50:40 24 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-10-22 16:50:40 24 [Note] InnoDB: The InnoDB memory heap is disabled
2015-10-22 16:50:40 24 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-10-22 16:50:40 24 [Note] InnoDB: Memory barrier is not used
2015-10-22 16:50:40 24 [Note] InnoDB: Compressed tables use zlib 1.2.7
2015-10-22 16:50:40 24 [Note] InnoDB: Using Linux native AIO
2015-10-22 16:50:40 24 [Note] InnoDB: Using CPU crc32 instructions
2015-10-22 16:50:40 24 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-10-22 16:50:40 24 [Note] InnoDB: Completed initialization of buffer pool
2015-10-22 16:50:40 24 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-10-22 16:50:40 24 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-10-22 16:50:40 24 [Note] InnoDB: Database physically writes the file full: wait...
2015-10-22 16:50:40 24 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-10-22 16:50:40 24 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-10-22 16:50:40 24 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-10-22 16:50:40 24 [Warning] InnoDB: New log files created, LSN=45781
2015-10-22 16:50:40 24 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-10-22 16:50:40 24 [Note] InnoDB: Doublewrite buffer created
2015-10-22 16:50:40 24 [Note] InnoDB: 128 rollback segment(s) are active.
2015-10-22 16:50:40 24 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-10-22 16:50:40 24 [Note] InnoDB: Foreign key constraint system tables created
2015-10-22 16:50:40 24 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-10-22 16:50:40 24 [Note] InnoDB: Tablespace and datafile system tables created.
2015-10-22 16:50:40 24 [Note] InnoDB: Waiting for purge to start
2015-10-22 16:50:40 24 [Note] InnoDB: 5.6.25 started; log sequence number 0
2015-10-22 16:50:40 24 [Note] Binlog end
2015-10-22 16:50:40 24 [Note] InnoDB: FTS optimize thread exiting.
2015-10-22 16:50:40 24 [Note] InnoDB: Starting shutdown...
2015-10-22 16:50:42 24 [Note] InnoDB: Shutdown completed; log sequence number 1625977
2015-10-22 16:50:42 0 [Note] /usr/sbin/mysqld (mysqld 5.6.25) starting as process 47 ...
2015-10-22 16:50:42 47 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-10-22 16:50:42 47 [Note] InnoDB: The InnoDB memory heap is disabled
2015-10-22 16:50:42 47 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-10-22 16:50:42 47 [Note] InnoDB: Memory barrier is not used
2015-10-22 16:50:42 47 [Note] InnoDB: Compressed tables use zlib 1.2.7
2015-10-22 16:50:42 47 [Note] InnoDB: Using Linux native AIO
2015-10-22 16:50:42 47 [Note] InnoDB: Using CPU crc32 instructions
2015-10-22 16:50:42 47 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-10-22 16:50:42 47 [Note] InnoDB: Completed initialization of buffer pool
2015-10-22 16:50:42 47 [Note] InnoDB: Highest supported file format is Barracuda.
2015-10-22 16:50:42 47 [Note] InnoDB: 128 rollback segment(s) are active.
2015-10-22 16:50:42 47 [Note] InnoDB: Waiting for purge to start
2015-10-22 16:50:42 47 [Note] InnoDB: 5.6.25 started; log sequence number 1625977
2015-10-22 16:50:42 47 [Note] Binlog end
2015-10-22 16:50:42 47 [Note] InnoDB: FTS optimize thread exiting.
2015-10-22 16:50:42 47 [Note] InnoDB: Starting shutdown...
2015-10-22 16:50:44 47 [Note] InnoDB: Shutdown completed; log sequence number 1625987
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h 93ef581fdf77 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
Note: new default config file not created.
Please make sure your config file is current
WARNING: Default config file /etc/mysql/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
Finished mysql_install_db
MySQL init process in progress...
MySQL init process in progress...
2015-10-22 16:50:45 0 [Note] mysqld (mysqld 5.6.25) starting as process 70 ...
2015-10-22 16:50:45 70 [Note] Plugin 'FEDERATED' is disabled.
2015-10-22 16:50:45 70 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-10-22 16:50:45 70 [Note] InnoDB: The InnoDB memory heap is disabled
2015-10-22 16:50:45 70 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-10-22 16:50:45 70 [Note] InnoDB: Memory barrier is not used
2015-10-22 16:50:45 70 [Note] InnoDB: Compressed tables use zlib 1.2.7
2015-10-22 16:50:45 70 [Note] InnoDB: Using Linux native AIO
2015-10-22 16:50:45 70 [Note] InnoDB: Using CPU crc32 instructions
2015-10-22 16:50:45 70 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-10-22 16:50:45 70 [Note] InnoDB: Completed initialization of buffer pool
2015-10-22 16:50:45 70 [Note] InnoDB: Highest supported file format is Barracuda.
2015-10-22 16:50:45 70 [Note] InnoDB: 128 rollback segment(s) are active.
2015-10-22 16:50:45 70 [Note] InnoDB: Waiting for purge to start
2015-10-22 16:50:45 70 [Note] InnoDB: 5.6.25 started; log sequence number 1625987
2015-10-22 16:50:45 70 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 0a36633e-78dd-11e5-a1a7-0242ac110089.
2015-10-22 16:50:45 70 [Note] Event Scheduler: Loaded 0 events
2015-10-22 16:50:45 70 [Note] mysqld: ready for connections.
Version: '5.6.25' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server (GPL)
2015-10-22 16:50:46 70 [Note] mysqld: Normal shutdown
MySQL init process in progress...
2015-10-22 16:50:46 70 [Note] Giving 0 client threads a chance to die gracefully
2015-10-22 16:50:46 70 [Note] Event Scheduler: Purging the queue. 0 events
2015-10-22 16:50:46 70 [Note] Shutting down slave threads
2015-10-22 16:50:46 70 [Note] Forcefully disconnecting 0 remaining clients
2015-10-22 16:50:46 70 [Note] Binlog end
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'partition'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'BLACKHOLE'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'ARCHIVE'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_METRICS'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_CMPMEM'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_CMP'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_LOCKS'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'INNODB_TRX'
2015-10-22 16:50:46 70 [Note] Shutting down plugin 'InnoDB'
2015-10-22 16:50:46 70 [Note] InnoDB: FTS optimize thread exiting.
2015-10-22 16:50:46 70 [Note] InnoDB: Starting shutdown...
MySQL init process in progress...
2015-10-22 16:50:47 70 [Note] InnoDB: Shutdown completed; log sequence number 1625997
2015-10-22 16:50:47 70 [Note] Shutting down plugin 'MEMORY'
2015-10-22 16:50:47 70 [Note] Shutting down plugin 'CSV'
2015-10-22 16:50:47 70 [Note] Shutting down plugin 'MRG_MYISAM'
2015-10-22 16:50:47 70 [Note] Shutting down plugin 'MyISAM'
2015-10-22 16:50:47 70 [Note] Shutting down plugin 'sha256_password'
2015-10-22 16:50:47 70 [Note] Shutting down plugin 'mysql_old_password'
2015-10-22 16:50:47 70 [Note] Shutting down plugin 'mysql_native_password'
2015-10-22 16:50:47 70 [Note] Shutting down plugin 'binlog'
2015-10-22 16:50:47 70 [Note] mysqld: Shutdown complete
MySQL init process done. Ready for start up.
2015-10-22 16:50:48 0 [Note] mysqld (mysqld 5.6.25) starting as process 1 ...
2015-10-22 16:50:48 1 [Note] Plugin 'FEDERATED' is disabled.
2015-10-22 16:50:48 1 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-10-22 16:50:48 1 [Note] InnoDB: The InnoDB memory heap is disabled
2015-10-22 16:50:48 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-10-22 16:50:48 1 [Note] InnoDB: Memory barrier is not used
2015-10-22 16:50:48 1 [Note] InnoDB: Compressed tables use zlib 1.2.7
2015-10-22 16:50:48 1 [Note] InnoDB: Using Linux native AIO
2015-10-22 16:50:48 1 [Note] InnoDB: Using CPU crc32 instructions
2015-10-22 16:50:48 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-10-22 16:50:48 1 [Note] InnoDB: Completed initialization of buffer pool
2015-10-22 16:50:48 1 [Note] InnoDB: Highest supported file format is Barracuda.
2015-10-22 16:50:48 1 [Note] InnoDB: 128 rollback segment(s) are active.
2015-10-22 16:50:48 1 [Note] InnoDB: Waiting for purge to start
2015-10-22 16:50:48 1 [Note] InnoDB: 5.6.25 started; log sequence number 1625997
2015-10-22 16:50:48 1 [Note] Server hostname (bind-address): '*'; port: 3306
2015-10-22 16:50:48 1 [Note] IPv6 is available.
2015-10-22 16:50:48 1 [Note] - '::' resolves to '::';
2015-10-22 16:50:48 1 [Note] Server socket created on IP: '::'.
2015-10-22 16:50:48 1 [Note] Event Scheduler: Loaded 0 events
2015-10-22 16:50:48 1 [Note] mysqld: ready for connections.
Version: '5.6.25' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
@Hippoom Were you able to test it again?
@tonivdv Hi, sorry for late response.
With "-v /var/lib/mysql" it works, with "-v /User/myaccount/mysql-data:/var/lib/mysql", No.
I'll try @MurgaNikolay 's approach sometime later.
@Hippoom If you want to use a data container you should do it the way I do it. There is no need to share your host directory with the guest because it's empty anyway.
Unless you have other requirements, but even then there are ways to access the files through different means.
Just want you to avoid struggling with host/guest permissions when it's not necessary :)
Let us know how it goes with @MurgaNikolay approach.
Cheers
@tonivdv
@MurgaNikolay 's solution works fine on my machine. I think it is ok to close the issue.
Sorry for the delay :)
Great. Yet another option to make available through the command line. I'll work on that.
Just to note:
With @MurgaNikolay solution, the owner of all the files written by docker is root of the host machine.
Not so quite. This solution map root on guest machine to root on host machine only.
This allow chown and chmod commands by nfs. But files/folders uids stay as is, and uids existed on guest machine can't be missing on host. So, for example, if you create file in docker machine (DM) by user ubuntu with UID 999, this file will be created on host machine with UID 999.
If file on DM will created by root, he will be created by root on host machine too.
-mapall
option map all UIDs/GIDs on DM to your local user on host machine, and root user too.
With "-v /var/lib/mysql" it works, with "-v /User/myaccount/mysql-data:/var/lib/mysql", No.
Same problem here. I prefer to link the volume to the hosts, so that the data will not lose if I recreate all containers.
I was running docker-machine using vboxsf on my mac, when I run the following command
It fails to mount the volume with correct permission, so no data can be written to the directory
Then I use docker-machine-nfs to mount /Users, then the command returns
Did I miss something?