Centos
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 IMAGECOMMAND 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 容器?
謝謝
啟用 SELinux 後,容器的捲應放置在
/var/lib/docker/volumes
. 主目錄中的捲將具有不允許 Docker 容器訪問它們的 SELinux 上下文。
您需要關閉容器,
./mysql/mysql.sock
從主機中刪除並重新啟動它。出於某種原因,那裡已經有一個套接字文件,需要將其刪除才能正確啟動服務。