Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot create directory when starting container (docker swarm with infinit) #146

Closed
mstenz opened this issue Jan 4, 2018 · 11 comments
Closed

Comments

@mstenz
Copy link

mstenz commented Jan 4, 2018

Hi,

when i want to run with host volume mounted i get this error message:
mariadb.1.5gzuua4no8v6@cl01-n03 | mkdir: cannot create directory '/var/lib/mysql/': File exists
any idea what may be the issue? After this error the container crashes directly.
Running service with:
docker service create \ --mount type=bind,source=/storage/docker1/mariadb/mariadbdata,target=/var/lib/mysql \ --name mariadb \ --network internal \ --replicas 1 \ -e MYSQL_ROOT_PASSWORD=xxxxxxxxx \ mariadb:10.3.2

@tianon
Copy link
Contributor

tianon commented Jan 4, 2018

Does /storage/docker1/mariadb/mariadbdata already exist, and is it a file instead of a directory?

@mstenz
Copy link
Author

mstenz commented Jan 4, 2018

It is a directory and it is empty

root@cl01-n03:/storage# ll docker1/mariadb/mariadbdata/
total 0
drwx------ 1 root root 0 Jan 4 00:39 ./
drwx------ 1 root root 0 Jan 4 00:28 ../

@tianon
Copy link
Contributor

tianon commented Jan 4, 2018

That's definitely strange -- I can't reproduce: 😕

$ mkdir test
$ docker run -it --rm -v "$PWD/test":/var/lib/mysql --name mariadb -e MYSQL_ROOT_PASSWORD=xxxxxxxxx mariadb:10.3
Unable to find image 'mariadb:10.3' locally
10.3: Pulling from library/mariadb
f49cf87b52c1: Already exists 
78032de49d65: Already exists 
84229c396ea3: Already exists 
c992bbf20f4e: Already exists 
380e932be3aa: Already exists 
8003c6d68fcd: Already exists 
603f60c36160: Already exists 
d5ed6a0d4e40: Pull complete 
c4dbcc87cd0d: Pull complete 
d1fa9c901568: Pull complete 
e857d9abcbb9: Pull complete 
Digest: sha256:5feb530514e4cfd0d3a9a8e4623b198f0d5569d11fb974631c50d94157073ea0
Status: Downloaded newer image for mariadb:10.3
Initializing database

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB 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  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 MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

Database initialized
MySQL init process in progress...
2018-01-04  0:44:01 0 [Note] mysqld (mysqld 10.3.3-MariaDB-10.3.3+maria~jessie) starting as process 101 ...
2018-01-04  0:44:01 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-01-04  0:44:01 0 [Note] InnoDB: Uses event mutexes
2018-01-04  0:44:01 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-01-04  0:44:01 0 [Note] InnoDB: Using Linux native AIO
2018-01-04  0:44:01 0 [Note] InnoDB: Number of pools: 1
2018-01-04  0:44:01 0 [Note] InnoDB: Using SSE2 crc32 instructions
2018-01-04  0:44:01 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
2018-01-04  0:44:01 0 [Note] InnoDB: Completed initialization of buffer pool
2018-01-04  0:44:01 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-01-04  0:44:01 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2018-01-04  0:44:01 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-01-04  0:44:01 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-01-04  0:44:01 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-01-04  0:44:01 0 [Note] InnoDB: Waiting for purge to start
2018-01-04  0:44:02 0 [Note] InnoDB: 5.7.20 started; log sequence number 1622809
2018-01-04  0:44:02 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2018-01-04  0:44:02 0 [Note] Plugin 'FEEDBACK' is disabled.
2018-01-04  0:44:02 0 [Note] InnoDB: Buffer pool(s) load completed at 180104  0:44:02
2018-01-04  0:44:02 0 [Warning] 'user' entry 'root@4b72b94c1e2f' ignored in --skip-name-resolve mode.
2018-01-04  0:44:02 0 [Warning] 'proxies_priv' entry '@% root@4b72b94c1e2f' ignored in --skip-name-resolve mode.
2018-01-04  0:44:02 0 [Note] Reading of all Master_info entries succeded
2018-01-04  0:44:02 0 [Note] Added new Master_info '' to hash table
2018-01-04  0:44:02 0 [Note] mysqld: ready for connections.
Version: '10.3.3-MariaDB-10.3.3+maria~jessie'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  mariadb.org binary distribution
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
2018-01-04  0:44:03 10 [Warning] 'proxies_priv' entry '@% root@4b72b94c1e2f' ignored in --skip-name-resolve mode.

2018-01-04  0:44:03 0 [Note] mysqld (unknown): Normal shutdown

2018-01-04  0:44:03 0 [Note] Event Scheduler: Purging the queue. 0 events
2018-01-04  0:44:03 0 [Note] InnoDB: FTS optimize thread exiting.
2018-01-04  0:44:03 0 [Note] InnoDB: Starting shutdown...
2018-01-04  0:44:03 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2018-01-04  0:44:03 0 [Note] InnoDB: Buffer pool(s) dump completed at 180104  0:44:03
2018-01-04  0:44:04 0 [Note] InnoDB: Shutdown completed; log sequence number 1622828
2018-01-04  0:44:04 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2018-01-04  0:44:04 0 [Note] mysqld: Shutdown complete


MySQL init process done. Ready for start up.

2018-01-04  0:44:04 0 [Note] mysqld (mysqld 10.3.3-MariaDB-10.3.3+maria~jessie) starting as process 1 ...
2018-01-04  0:44:04 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-01-04  0:44:04 0 [Note] InnoDB: Uses event mutexes
2018-01-04  0:44:04 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-01-04  0:44:04 0 [Note] InnoDB: Using Linux native AIO
2018-01-04  0:44:04 0 [Note] InnoDB: Number of pools: 1
2018-01-04  0:44:04 0 [Note] InnoDB: Using SSE2 crc32 instructions
2018-01-04  0:44:04 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
2018-01-04  0:44:04 0 [Note] InnoDB: Completed initialization of buffer pool
2018-01-04  0:44:04 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-01-04  0:44:04 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2018-01-04  0:44:04 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-01-04  0:44:04 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-01-04  0:44:04 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-01-04  0:44:04 0 [Note] InnoDB: 5.7.20 started; log sequence number 1622828
2018-01-04  0:44:04 0 [Note] Plugin 'FEEDBACK' is disabled.
2018-01-04  0:44:04 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2018-01-04  0:44:04 0 [Note] InnoDB: Buffer pool(s) load completed at 180104  0:44:04
2018-01-04  0:44:04 0 [Note] Server socket created on IP: '::'.
2018-01-04  0:44:04 0 [Warning] 'proxies_priv' entry '@% root@4b72b94c1e2f' ignored in --skip-name-resolve mode.
2018-01-04  0:44:04 0 [Note] Reading of all Master_info entries succeded
2018-01-04  0:44:04 0 [Note] Added new Master_info '' to hash table
2018-01-04  0:44:04 0 [Note] mysqld: ready for connections.
Version: '10.3.3-MariaDB-10.3.3+maria~jessie'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution

@mstenz
Copy link
Author

mstenz commented Jan 4, 2018

repeated what you did:

root@cl01-n01:/storage# docker run -it --rm -v "/storage/docker1/mariadb/maradbdata":/var/lib/mysql --name mariadb -e MYSQL_ROOT_PASSWORD=xxxxxxxxx mariadb:10.3
Unable to find image 'mariadb:10.3' locally
10.3: Pulling from library/mariadb
Digest: sha256:5feb530514e4cfd0d3a9a8e4623b198f0d5569d11fb974631c50d94157073ea0
Status: Downloaded newer image for mariadb:10.3
mkdir: cannot create directory '/var/lib/mysql/': File exists

@tianon
Copy link
Contributor

tianon commented Jan 4, 2018

Ok, what type of filesystem is running on /storage/docker1/mariadb/maradbdata? (df -hT /storage/docker1/mariadb/maradbdata would be an easy way to find out)

Where'd you get your Docker install from? Any AppArmor or SELinux installed on your host?

@tianon
Copy link
Contributor

tianon commented Jan 4, 2018

(Also, the amount of people seeing your request for help would probably be higher if this were posted in the Docker Community Forums, the Docker Community Slack, or Stack Overflow instead.)

@mstenz
Copy link
Author

mstenz commented Jan 4, 2018

This is a infinit storage cluster using FUSE:

root@cl01-n03:/storage# df -hT /storage/docker1/mariadb/maradbdata
Filesystem Type Size Used Avail Use% Mounted on
/dev/fuse fuse 84G 2.6M 84G 1% /storage/docker1

running on Ubuntu 16.04. i don't know if there is any apparmor or selinux on it by default. i have not installed it

@tianon
Copy link
Contributor

tianon commented Jan 4, 2018

Oh, then I imagine this is probably a quirk of their FUSE implementation, and I'd recommend taking this up with the infinit folks to see if they can help figure out what's going on. Sorry!

(Closing, since I can't reproduce, so I don't think this is a problem with the image.)

@tianon tianon closed this as completed Jan 4, 2018
@mstenz
Copy link
Author

mstenz commented Jan 4, 2018

I have found the issue. it is because FUSE don't allow to set different user for filesystem (chown). Is there any way to run mariadb container with different user (root)?

@tianon
Copy link
Contributor

tianon commented Jan 4, 2018

Yep, see #59. To run as root will likely be tricky, but running as a different non-root user should be pretty easy.

@mstenz
Copy link
Author

mstenz commented Jan 4, 2018

thx, I have managed to get arround this with using this infinit command option when mounting the FUSE volume:
--fuse-option allow_other
Changing fuse config in /etc/fuse.conf was not working, only this direct manual option. It works now without any change to the mariadb image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants