Docker-compose 无法启动 mysql,/tmp 权限被拒绝

Wai*_*ski 5 docker docker-compose

我正在尝试使用 docker-compose 从 docker hub 的普通mariadb映像启动 docker 容器。虽然之前一切正常,但我现在收到错误消息Can't create/write to file '/tmp/ibLTxiq7' (Errcode: 13 "Permission denied")。这是完整的日志:

139707238336448 [Note] /usr/sbin/mysqld (mysqld 10.1.14-MariaDB-1~jessie) starting as process 51 ...
139707238336448 [Note] InnoDB: Using mutexes to ref count buffer pool pages
139707238336448 [Note] InnoDB: The InnoDB memory heap is disabled
139707238336448 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
139707238336448 [Note] InnoDB: Memory barrier is not used
139707238336448 [Note] InnoDB: Compressed tables use zlib 1.2.8
139707238336448 [Note] InnoDB: Using Linux native AIO
139707238336448 [Note] InnoDB: Using SSE crc32 instructions
139707238336448 [ERROR] mysqld: Can't create/write to file '/tmp/ibLTxiq7' (Errcode: 13 "Permission denied")
7f10205047c0  InnoDB: Error: unable to create temporary file; errno: 13
139707238336448 [ERROR] Plugin 'InnoDB' init function returned error.
139707238336448 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
139707238336448 [ERROR] Unknown/unsupported storage engine: InnoDB
139707238336448 [ERROR] Aborting
Run Code Online (Sandbox Code Playgroud)

我不明白,/tmp日志中的文件夹是指宿主机还是容器?我该如何解决这个问题?

我尝试运行(作为 root 用户)的命令是docker-compose up db. 我已经检查过磁盘上确实有空间。我的操作系统 Ubuntu 16.04。

更新:我的docker-compose.yml-file

139707238336448 [Note] /usr/sbin/mysqld (mysqld 10.1.14-MariaDB-1~jessie) starting as process 51 ...
139707238336448 [Note] InnoDB: Using mutexes to ref count buffer pool pages
139707238336448 [Note] InnoDB: The InnoDB memory heap is disabled
139707238336448 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
139707238336448 [Note] InnoDB: Memory barrier is not used
139707238336448 [Note] InnoDB: Compressed tables use zlib 1.2.8
139707238336448 [Note] InnoDB: Using Linux native AIO
139707238336448 [Note] InnoDB: Using SSE crc32 instructions
139707238336448 [ERROR] mysqld: Can't create/write to file '/tmp/ibLTxiq7' (Errcode: 13 "Permission denied")
7f10205047c0  InnoDB: Error: unable to create temporary file; errno: 13
139707238336448 [ERROR] Plugin 'InnoDB' init function returned error.
139707238336448 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
139707238336448 [ERROR] Unknown/unsupported storage engine: InnoDB
139707238336448 [ERROR] Aborting
Run Code Online (Sandbox Code Playgroud)

更新2:

令人惊讶的是,我似乎(至少暂时)解决了这个问题,通过为数据库容器添加卷安装路径:

https-portal:
  image: steveltn/https-portal
  ports:
    - '80:80'
    - '443:443'
  links:
    - wordpress
  restart: always
  environment:
    DOMAINS: 'domain.com -> http://wordpress'
    STAGE: 'production'
wordpress:
  image: wordpress
  links:
    - db:mysql
  volumes:
    - ~/wordpress/wp_html:/var/www/html
db:
  image: mariadb
  environment:
    MYSQL_ROOT_PASSWORD: [---]
Run Code Online (Sandbox Code Playgroud)

然而,这实际上不会影响任何东西,它只是打印一条警告,表明未使用卷安装(实际上没有),因为容器之前是使用不同的卷创建的,并且使用了旧卷。尽管如此,原来的问题还是消失了。对于导致这种行为的原因有什么想法吗?

小智 0

我遇到了这个问题,但在不同的情况下,我将 docker 数据文件夹迁移到一个新文件夹(安装在新磁盘中) cp -R /var/lib/docker/ /data/ ,然后更改/etc/docker/daemon.json

{
  "data-root": "/data/docker"
}
Run Code Online (Sandbox Code Playgroud)

我发现真正的原因是在使用时cp -R,docker文件夹的perm是711(rwx--x--x)我将其(仅文件夹)更改为755(rwxr-xr-x)然后一切顺利

奇怪但有效