Docker中的Sphinx:在“读取初始通信数据包”时丢失了与MySQL服务器的连接,系统错误:0

时间:2018-03-23 14:46:43

标签: docker sphinx

我无法从外部连接到Docker中的Sphinx。

在docker容器连接中工作正常:

root@b8161ac2de3e:/app# mysql -h127.0.0.1 -P 9306
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 2.3.2-id64-beta (4409612)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input 
statement.

mysql>

Docker转发端口:

b8161ac2de3e        test_sphinx          "searchd.sh"   9 minutes ago       Up 9 minutes        9000/tcp, 0.0.0.0:9306->9306/tcp   test_sphinx_1

但是当我尝试从外部容器连接时,我得到了这个:

vagrant@test:/srv/projects/test$ mysql -h0.0.0.0 -P 9306
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

你有什么想法吗?

UP! 添加docker-compose.yml

version: '3'

services:

  web:
     image: nginx
     depends_on:
       - php-fpm
     volumes:
       - .:/app
       - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
       - ./docker/nginx/frontend.conf:/etc/nginx/conf.d/default.conf
     restart: ${RESTART}
     ports:
       - 80:80

    php-fpm:
      build:
        context: ./docker/php-fpm
        args:
          ENABLE_XDEBUG: ${PHP_ENABLE_XDEBUG}
          PHP_CLI_UID: ${PHP_CLI_UID}
          PHP_CLI_GID: ${PHP_CLI_GID}
          PHP_FPM_UID: ${PHP_FPM_UID}
          PHP_FPM_GID: ${PHP_FPM_GID}
      environment:
        XDEBUG_CONFIG: remote_host=${XDEBUG_REMOTE_HOST} remote_port=${XDEBUG_REMOTE_PORT} remote_enable=On
        PHP_IDE_CONFIG: serverName=app
      volumes:
        - .:/app
        - ./docker/php-fpm/config/php.ini:/usr/local/etc/php/php.ini
        - ./sysconfig/etc/freetds:/etc/freetds
        - ./sysconfig/etc/odbc.ini:/etc/odbc.ini
        - ./sysconfig/etc/odbcinst.ini:/etc/odbcinst.ini
        - ./sysconfig/usr/local/sphinxsearch/etc/sphinx.conf:/etc/sphinxsearch/sphinx.conf
        - ./sysconfig/usr/local/sphinxsearch:/usr/local/sphinxsearch
        - ./docker/sphinx/data:/usr/local/sphinxsearch/var/data
        - ./docker/sphinx/log:/usr/local/sphinxsearch/var/log
      restart: ${RESTART}

  mysql:
      image: mysql
      restart: always
      environment:
        - MYSQL_ROOT_PASSWORD=root
        - MYSQL_DATABASE=blog
      ports:
        - 3306:3306

  sphinx:
    build:
      context: ./docker/php-fpm
      args:
        ENABLE_XDEBUG: ${PHP_ENABLE_XDEBUG}
        PHP_CLI_UID: ${PHP_CLI_UID}
        PHP_CLI_GID: ${PHP_CLI_GID}
        PHP_FPM_UID: ${PHP_FPM_UID}
        PHP_FPM_GID: ${PHP_FPM_GID}
    environment:
      XDEBUG_CONFIG: remote_host=${XDEBUG_REMOTE_HOST} remote_port=${XDEBUG_REMOTE_PORT} remote_enable=On
      PHP_IDE_CONFIG: serverName=app
    command: /app/docker/php-fpm/searchd.sh
    volumes:
        - .:/app
        - ./docker/php-fpm/config/php.ini:/usr/local/etc/php/php.ini
        - ./sysconfig/etc/freetds:/etc/freetds
        - ./sysconfig/etc/odbc.ini:/etc/odbc.ini
        - ./sysconfig/etc/odbcinst.ini:/etc/odbcinst.ini
        - ./sysconfig/usr/local/sphinxsearch/etc/sphinx.conf:/etc/sphinxsearch/sphinx.conf
        - ./sysconfig/usr/local/sphinxsearch:/usr/local/sphinxsearch
        - ./docker/sphinx/data:/usr/local/sphinxsearch/var/data
    restart: ${RESTART}
    ports:
      - 9306:9306
    networks:
      - default
      - web

  redis:
    image: redis:latest

这启动了服务,除了sphinx之外的其他服务在主机上可用。

0 个答案:

没有答案