CentOS 上的 MariaDB docker 容器无法启动

CentOS 上的 MariaDB docker 容器无法启动

我有以下docker-compose:

version: "2"
services:
  webserver:
    image: orsolin/docker-php-5.3-apache
    environment:
      ALLOW_OVERRIDE: "true"
      HTTP_PROXY: "${HTTP_PROXY}"
      HTTPS_PROXY: "${HTTPS_PROXY}"
      NO_PROXY: "${NO_PROXY}"
    ports:
      - "8000:80"
    depends_on:
      - db
    volumes:
      - ./app:/var/www/html/

  db:
    image: centos/mariadb-102-centos7
    restart: always
    volumes:
      - ./mysql:/var/lib/mysql/:rw
    environment:
      MYSQL_ROOT_PASSWORD: *redacted*
      MYSQL_USER: *redacted*
      MYSQL_PASSWORD: *redacted*
      MYSQL_DATABASE: *redacted*
      HTTP_PROXY: "${HTTP_PROXY}"
      HTTPS_PROXY: "${HTTPS_PROXY}"
      NO_PROXY: "${NO_PROXY}"
    ports:
      - "8889:3306"

  adminer:
    image: adminer
    restart: always
    environment:
      ADMINER_DEFAULT_DB_DRIVER: mysql
      ADMINER_DEFAULT_DB_HOST: mariadb
      ADMINER_DEFAULT_DB_NAME: adminer
      ADMINER_DESIGN: nette
      ADMINER_PLUGINS: tables-filter tinymce
      HTTP_PROXY: "${HTTP_PROXY}"
      HTTPS_PROXY: "${HTTPS_PROXY}"
      NO_PROXY: "${NO_PROXY}"
    ports:
      - "8282:8080"

运行 docker-compose up -d 后,容器继续重新启动,运行时我可以看到以下内容docker logs --tail 50 --follow --timestamps 01e2489d4526

2019-07-11T10:03:45.554517000Z 2019-07-11 10:03:45 140548938721472 [Note] Plugin 'FEEDBACK' is disabled.
2019-07-11T10:03:45.559329000Z 2019-07-11 10:03:45 140548938721472 [Note] Server socket created on IP: '::'.
2019-07-11T10:03:45.559835000Z 2019-07-11 10:03:45 140548938721472 [ERROR] Can't start server : Bind on unix socket: Permission denied
2019-07-11T10:03:45.560319000Z 2019-07-11 10:03:45 140548938721472 [ERROR] Do you already have another mysqld server running on socket: /var/lib/mysql/mysql.sock ?
2019-07-11T10:03:45.560796000Z 2019-07-11 10:03:45 140548938721472 [ERROR] Aborting

这是docker ps输出:CONTAINER ID IMAGE

    COMMAND                  CREATED             STATUS                         PORTS                    NAMES
8d7e8d571a1b        orsolin/docker-php-5.3-apache   "apache2-foreground"     7 minutes ago       Up 7 minutes                   0.0.0.0:8000->80/tcp     docker_webserver_1
5f0b1bb872c7        adminer                         "entrypoint.sh doc..."   7 minutes ago       Up 7 minutes                   0.0.0.0:8282->8080/tcp   docker_adminer_1
01e2489d4526        centos/mariadb-102-centos7      "container-entrypo..."   7 minutes ago       Restarting (1) 2 minutes ago                            docker_db_1

我该如何解决这个问题,记住我也需要能够从其他容器连接到 mariadb 容器?

谢谢

答案1

启用 SELinux 后,容器的卷应放置在 的子目录中/var/lib/docker/volumes。主目录中的卷将具有不允许 Docker 容器访问的 SELinux 上下文。

答案2

您需要关闭容器,./mysql/mysql.sock从主机中删除它,然后重新启动它。由于某种原因,那里已经有一个套接字文件,需要将其删除才能正确启动服务。

答案3

错误很明显,您要么停止其他 mysql 服务,要么更改配置文件中的端口:

[mysqld]

端口= 1234

相关内容