PRedis / Laravel无法在启动时解析主机-[tcp://:6379]

时间:2018-07-31 12:24:05

标签: laravel docker redis rancher predis

我在Rancher上的Laravel / Redis泊坞窗堆栈出现问题。每当它启动时,Predis都会出现此错误

php_network_getaddresses: getaddrinfo failed: Name does not resolve [tcp://:6379]

Docker-compose.yml:


        services:
      app:
        image: REDACTED/services-intranet:${APP_VERSION}
        environment:
          - DB_MIGRATE=true
          - DB_CONNECTION=mysql
          - DB_HOST=${STAGING_DB_HOST}
          - DB_PORT=${STAGING_DB_PORT}
          - DB_DATABASE=${STAGING_DB_DATABASE}
          - DB_USERNAME=${STAGING_DB_USERNAME}
          - DB_PASSWORD=${STAGING_DB_PASSWORD}
          - REDIS_HOST=redis
          - REDIS_PORT=6379
          - JWT_TOKEN=${JWT_TOKEN}
          - APP_KEY=${STAGING_APP_KEY}
          - APP_URL=${INTRANET_URL}
          - AUTH_URL=${AUTH_URL}
          - AUDIT_URL=${AUDIT_URL}
          - BILLING_URL=${BILLING_URL}
          - BUSINESSES_URL=${BUSINESSES_URL}
          - GROUPS_URL=${GROUPS_URL}
          - MESSAGING_URL=${MESSAGING_URL}
          - PERMISSIONS_URL=${PERMISSIONS_URL}
          - UI_URL=${UI_URL}
          - USERS_URL=${USERS_URL}
        labels:
            io.rancher.scheduler.affinity:host_label: type=node
            io.rancher.scheduler.affinity:host_label: services=true
        depends_on:
          - redis
        command: sh -c '/run/wait-for.sh redis:6379 --timeout=30 --strict -- /run/start.sh'
        links:
          - redis:redis
      redis:
        image: REDACTED/services-redis:staging-latest
        command: ["redis-server", "--appendonly", "yes"]
        volumes:
          - intranet-redis:/data
        labels:
          io.rancher.scheduler.affinity:host_label: type=database
          io.rancher.scheduler.affinity:host_label: redis=true
        restart: always
    volumes:
      intranet-redis:
        driver: local

wait-for.sh脚本可以正常工作,并且发现redis没问题。但似乎在应用容器的supervisord.conf中失败了


    [supervisord]
    logfile=/var/log/supervisor/supervisord.log     ; supervisord log file
    logfile_maxbytes=50MB                           ; maximum size of logfile before rotation
    logfile_backups=10                              ; number of backed up logfiles
    loglevel=error                                  ; info, debug, warn, trace
    pidfile=/var/run/supervisord.pid                ; pidfile location
    nodaemon=true                                   ; run supervisord NOT as a daemon
    minfds=1024                                     ; number of startup file descriptors
    minprocs=200                                    ; number of process descriptors
    user=root                                       ; default user
    childlogdir=/var/log/supervisor/                ; where child log files will live

    [program:php-fpm]
    command=php-fpm7 -F
    stdout_logfile=/dev/stdout
    stdout_logfile_maxbytes=0
    stderr_logfile=/dev/stderr
    stderr_logfile_maxbytes=0
    autorestart=false
    startretries=0

    [program:nginx]
    command=nginx -g 'daemon off;'
    stdout_logfile=/dev/stdout
    stdout_logfile_maxbytes=0
    stderr_logfile=/dev/stderr
    stderr_logfile_maxbytes=0
    autorestart=false
    startretries=0

    [program:laravel-worker]
    process_name=%(program_name)s_%(process_num)02d
    command=php /web/html/artisan queue:work --sleep=3 --tries=3
    autostart=true
    autorestart=true
    user=root
    numprocs=2
    redirect_stderr=true
    stdout_logfile=/dev/stdout
    stdout_logfile_maxbytes = 0
    stderr_logfile=/dev/stderr
    stderr_logfile_maxbytes=0

如果我通过SSH进入容器,则可以使用redis-cli ping redis服务器,并且所有DNS解析均已正确完成,仅是初始启动。

0 个答案:

没有答案