Can you show your env without passwords?
Docker on production , error - RedisException READONLY You can't write against a read only replica.
Hello , I am trying to push a nginx server with docker on production . I am having error with Redis in production server .
It is giving this error -
RedisException
READONLY You can't write against a read only replica.
in localhost it is working . it is giving this error only on production .
My docker-compose.yml -
version: '3.8'
networks:
laravel:
name: laravel
services:
nginx:
build:
context: .
dockerfile: nginx.prod.dockerfile
container_name: nginx
volumes:
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
depends_on:
- php
- mysql
- redis
ports:
- 80:80
- 443:443
networks:
- laravel
php:
build:
context: .
dockerfile: php.prod.dockerfile
container_name: php
networks:
- laravel
mysql:
image: mysql:5.7.32
container_name: mysql
ports:
- 4306:3306
environment:
MYSQL_DATABASE: laraveldb
MYSQL_USER: laravel
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: secret
networks:
- laravel
composer:
image: composer:latest
container_name: composer
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
networks:
- laravel
artisan:
build:
context: .
dockerfile: php.prod.dockerfile
container_name: artisan
working_dir: /var/www/html
entrypoint: ["php", "artisan"]
networks:
- laravel
npm:
image: node:13.7
container_name: npm
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
entrypoint: ["npm"]
networks:
- laravel
# phpunit:
# build:
# context: .
# dockerfile: php.prod.dockerfile
# container_name: phpunit
# working_dir: /var/www/html
# entrypoint: ["/var/www/html/vendor/bin/phpunit"]
# networks:
# - laravel
redis:
image: redis:latest
container_name: redis
ports:
- 6379:6379
networks:
- laravel
scheduler:
build:
context: .
dockerfile: php.prod.dockerfile
container_name: scheduler
working_dir: /var/www/html
entrypoint: ["php", "artisan", "schedule:work"]
networks:
- laravel
certbot:
image: certbot/certbot
volumes:
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
nginx.prod.dockerfile
FROM nginx:stable-alpine
ADD ./nginx/default.prod.conf /etc/nginx/conf.d/default.conf
RUN mkdir -p /var/www/html
ADD ./src/ /var/www/html
php.prod.dockerfile
FROM php:8.1-fpm-alpine
ADD ./php/www.conf /usr/local/etc/php-fpm.d/www.conf
RUN addgroup -g 1000 laravel && adduser -G laravel -g laravel -s /bin/sh -D laravel
RUN mkdir -p /var/www/html
ADD ./src/ /var/www/html
RUN chmod -R 777 /var/www/html/storage
RUN chmod -R 777 /var/www/html/bootstrap/cache
RUN docker-php-ext-install pdo pdo_mysql
RUN apk --no-cache add pcre-dev ${PHPIZE_DEPS} \
&& pecl install redis \
&& docker-php-ext-enable redis \
&& apk del pcre-dev ${PHPIZE_DEPS}
RUN chown laravel:laravel /var/www/html
I fix it by adding command to docker and disable the replica-read-only config
add this to your redis docker compose
command: redis-server --appendonly yes --replica-read-only no
then you could try to verify if the replica-read-only is disable using
redis-cli > config get replica-read-only command , if the result is no then it successful to disable.
Please or to participate in this conversation.