In swarm mode, containers can be deployed to any connected nodes. I created the nfs shared folder as the mysql data folder on host1.
mkdir -p /nfs/data-volume
In another host2, it connects to this shared folder. And added the necessary permission. I tried this nfs shared folder by reading and writing a text file to it. He worked very well. (There was no permission error) After this nfs configuration, I defined my container volume as follows:
mysqldb-read:
image: demo/db-slave
ports:
- "3308:3306"
volumes:
- /nfs/data-volume:/var/lib/mysql
Result: If the mysql container starts on host1, it works very well. If the mysql container is running on host2, it does not start. But the container does not exit, the stream remains there and looks somehow to wait. By running the log validation command:
docker logs -f mymysql
Logs are displayed here:
2017-06-07T02:40:13.627195Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use
2017-06-07T02:40:13.632313Z 0 [Note] mysqld (mysqld 5.7.18-log) starting as process 52 ...
2017-06-07T02:40:13.648010Z 0 [Note] InnoDB: PUNCH HOLE support available
2017-06-07T02:40:13.648054Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-06-07T02:40:13.648059Z 0 [Note] InnoDB: Uses event mutexes
2017-06-07T02:40:13.648062Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-06-07T02:40:13.648066Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-06-07T02:40:13.648069Z 0 [Note] InnoDB: Using Linux native AIO
2017-06-07T02:40:13.648326Z 0 [Note] InnoDB: Number of pools: 1
2017-06-07T02:40:13.648770Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-06-07T02:40:13.651011Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2017-06-07T02:40:13.760444Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-06-07T02:40:13.829981Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
, .
mysqld -uroot -proot
.
, nfs. googled , nfs . -, ? ?