Docker redis configuration

Hello,

I am having issues understanding the redis configuration for docker

They are no redis related variables here:

Bringing up my docker compose with not specifying anything beyond that, will bring constantly this error:

If I set password via this:
image

I get the following error:
image

This is my current docker compose:

services:

  # You can comment this webserver section if you want to use another webserver/proxy or test PeerTube in local
  # webserver:
  #   image: chocobozzz/peertube-webserver:latest
  #   # If you don't want to use the official image and build one from sources:
  #   # build:
  #   #   context: .
  #   #   dockerfile: ./support/docker/production/Dockerfile.nginx
  #   env_file:
  #     - .env
  #   ports:
  #    - "800:80"
  #    - "4433:443"
  #   volumes:
  #     - type: bind
  #       # Switch sources if you downloaded the whole repository
  #       #source: ../../nginx/peertube
  #       source: ./docker-volume/nginx/peertube.file
  #       target: /etc/nginx/conf.d/peertube.template
  #     - assets:/var/www/peertube/peertube-latest/client/dist:ro
  #     - ./docker-volume/data:/var/www/peertube/storage
  #     - certbot-www:/var/www/certbot
  #     - ./docker-volume/certbot/conf:/etc/letsencrypt
  #   depends_on:
  #     - peertube
  #   restart: "always"

  # You can comment this certbot section if you want to use another webserver/proxy or test PeerTube in local
  # certbot:
  #   container_name: certbot
  #   image: certbot/certbot
  #   volumes:
  #     - ./docker-volume/certbot/conf:/etc/letsencrypt
  #     - certbot-www:/var/www/certbot
  #   restart: unless-stopped
  #   entrypoint: /bin/sh -c "trap exit TERM; while :; do certbot renew --webroot -w /var/www/certbot; sleep 12h & wait $${!}; done;"
  #   depends_on:
  #     - webserver

  peertube:
    # If you don't want to use the official image and build one from sources:
    # build:
    #   context: .
    #   dockerfile: ./support/docker/production/Dockerfile.bookworm
    image: chocobozzz/peertube:production-bookworm
    # Use a static IP for this container because nginx does not handle proxy host change without reload
    # This container could be restarted on crash or until the postgresql database is ready for connection
    #networks:
      #default:
        #ipv4_address: 172.26.0.20
        #ipv6_address: fdab:e4b3:21a2:ef1b::42
    env_file:
      - stack.env

    #ports:
     #- "1935:1935" # Comment if you don't want to use the live feature
     #- "9000:9000" # Uncomment if you use another webserver/proxy or test PeerTube in local, otherwise not suitable for production
    volumes:
      # Remove the following line if you want to use another webserver/proxy or test PeerTube in local
      # - assets:/app/client/dist
      - ${WD}/docker-volume/data:/data
      - ${WD}/docker-volume/config:/config
    depends_on:
      - postgres
      - redis
      - postfix
    environment:
      - PEERTUBE_REDIS_HOSTNAME=peertube_redis
      - PEERTUBE_REDIS_PORT=6379         # Redis port
      - PEERTUBE_REDIS_AUTH=NOAUTH
    restart: "always"

  postgres:
    image: postgres:13-alpine
    env_file:
      - stack.env
    volumes:
      - ${WD}/docker-volume/db:/var/lib/postgresql/data
    restart: "always"

  pgbackups:
    image: prodrigestivill/postgres-backup-local
    restart: always
    #user: postgres:postgres # Optional: see below
    volumes:
        - ${SB}:/backups
    links:
        - postgres
    depends_on:
        - postgres
    environment:
        - POSTGRES_HOST=postgres
        - POSTGRES_DB=${POSTGRES_DB}
        - POSTGRES_USER=${POSTGRES_USER}
        - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
     #  - POSTGRES_PASSWORD_FILE=/run/secrets/db_password <-- alternative for POSTGRES_PASSWORD (to use with docker secrets)
        - POSTGRES_EXTRA_OPTS=-Z1 --schema=public --blobs
        - SCHEDULE=@daily
        - BACKUP_ON_START=TRUE
        - BACKUP_KEEP_DAYS=7
        - BACKUP_KEEP_WEEKS=4
        - BACKUP_KEEP_MONTHS=6
        #- HEALTHCHECK_PORT=8080

  redis:
    image: redis:6-alpine
    hostname: "peertube_redis"
    volumes:
      - ${WD}/docker-volume/redis:/data
    environment:
      - REDIS_PASSWORD=${REDIS_PW}
    restart: "always"


  postfix:
    image: mwader/postfix-relay
    env_file:
      - stack.env
    volumes:
      - ${WD}/docker-volume/opendkim/keys:/etc/opendkim/keys
    restart: "always"

networks:
  default:
    external: true
    name: ext
    enable_ipv6: false
    #ipam:
      #driver: default
      #config:
      #- subnet: 172.26.0.0/16
      #- subnet: fdab:e4b3:21a2:ef1b::/64

and my stack.env:

POSTGRES_USER=db_user
POSTGRES_PASSWORD=db_pwd
POSTGRES_DB=peertube
PEERTUBE_DB_NAME=peertube
PEERTUBE_DB_USERNAME=db_user
PEERTUBE_DB_PASSWORD=db_pwd
PEERTUBE_DB_SSL=false
PEERTUBE_DB_HOSTNAME=feditubo-postgres-1
PEERTUBE_WEBSERVER_HOSTNAME=my_domain
PEERTUBE_WEBSERVER_HTTPS=true
PEERTUBE_SECRET=secret
PEERTUBE_SMTP_USERNAME=admin@my_domain
PEERTUBE_SMTP_PASSWORD=smtp_pw
PEERTUBE_SMTP_HOSTNAME=smtp.server
PEERTUBE_SMTP_PORT=587
PEERTUBE_SMTP_FROM=admin@my_domain
PEERTUBE_SMTP_TLS=false
PEERTUBE_SMTP_DISABLE_STARTTLS=false
PEERTUBE_ADMIN_EMAIL=admin@my_domain
POSTFIX_myhostname=my_domain
OPENDKIM_DOMAINS=my_domain=peertube
OPENDKIM_RequireSafeKeys=no
PEERTUBE_OBJECT_STORAGE_ENABLED=true
PEERTUBE_OBJECT_STORAGE_ENDPOINT=s3.server
PEERTUBE_OBJECT_STORAGE_REGION=region
PEERTUBE_OBJECT_STORAGE_PROXY_PROXIFY_PRIVATE_FILES=true
PEERTUBE_OBJECT_STORAGE_CREDENTIALS_ACCESS_KEY_ID=id
PEERTUBE_OBJECT_STORAGE_CREDENTIALS_SECRET_ACCESS_KEY=secret
PEERTUBE_OBJECT_STORAGE_MAX_UPLOAD_PART=1000000000
PEERTUBE_OBJECT_STORAGE_STREAMING_PLAYLISTS_BUCKET_NAME=feditubo
PEERTUBE_OBJECT_STORAGE_STREAMING_PLAYLISTS_PREFIX=streaming-playlists/
PEERTUBE_OBJECT_STORAGE_STREAMING_PLAYLISTS_BASE_URL=https://feditubo.s3.server
PEERTUBE_OBJECT_STORAGE_UPLOAD_ACL=public
PEERTUBE_OBJECT_STORAGE_WEB_VIDEOS_BUCKET_NAME=fedituboyt
PEERTUBE_OBJECT_STORAGE_WEB_VIDEOS_PREFIX=web-videos/
PEERTUBE_OBJECT_STORAGE_WEB_VIDEOS_BASE_URL=https://feditubo.s3.server
WD=/home/kireek/docker/feditubo
SB=/mnt/backrest/mysqlbackup/peertube
private_files_require_auth=true
REDIS_PW=NOAUTH

what I fail to understand is how to apply this: PeerTube/support/docker/production/config/custom-environment-variables.yaml at develop · Chocobozzz/PeerTube · GitHub

in this context. do these goes in the compose, in the environment of peertube, of redis? do they do in environment variable? are they keys, values? both?

in short: please explain how to configure redis in docker setup please.

thank you very much!

Hello if you do it like this Docker guide | PeerTube documentation, then everything starts correctly. Redis doesn’t require any configuration, just fill in the .env file. Also, what you wrote above, the variables are specified in the file.

Redis is a powerful database software, but we often use it as cache for fast retrieval of current data. You probably expected us to define ports: for Redis and configure PeerTube to connect to it to utilize it. But that ports: section in docker-compose file is for exposing container’s port to Operating System’s physical network interface. Docker creates a virtual network device unique to every docker-compose file. And containers in same docker-compose file connect to same virtual network device to communicate among each other. Peertube is pre-configured to connect to Redis’ port through that virtual network. Since that virtula network is isolated, it is preconfigured to NOT use a password. But you still set a password for Redis. This is confusing to PeerTube.

Here is what is odd. It seems like you are not using Nginx on PeerTube’s docker-compose file. That is okay, I too use an external instance of Nginx to route traffic to PeerTube. But if you are going to use external nginx, then you should expose PeerTube’s port 9000. Since you are not exposing that port, PeerTube has no way of communicating.

Hello both, thank you for your answers.

@bestperson
That is the guide I have been following; for peertube to work, thats all it needs. But it does throw those noauth issues. and to me, it is not stable: I cannot upload more than one video at a time. If I dont want the transcoding or the move to external storage to fail, I need those operations to finish before I upload the next video. I dont think thats intentional.

I know how to make the « .env » to work. In the case of portainer, its called stack.env and it must be referenced in the services. like it is on my docker compose. but I dont know how to get the custom-environment.variables to work. i dont know where to put them and configure them. they dont go in .env / stack.env: it is not the correct format. do they go in the compose? in a second environment file? how do i reference it in the compose? I am sorry, i know its a docker question and not so much of peertube…

@murteza
I figured it out (found it from the yaml file of a yunohost installation file)
the fixed configuration is:

  redis:
    image: redis:6-alpine
    hostname: "peertube_redis"
    volumes:
      - ${WD}/docker-volume/redis:/data
    environment:
      - auth=null
    restart: "always"

Not using the provided nginx is not odd, I am following the instructions:

INFO

The docker compose file includes a configured web server. You can skip this part and comment the appropriate section in the docker compose if you use another webserver/proxy.

I am using Nginx Proxy Manager on top / alongside Peertube and thats what serving as webserver.

Also the port is not exposed, because there is no need. If you share the application with nginxproxymanager (whose ports ARE exposed), they share network and npm can « see » the ports through the shared network without having to expose them to the host. Thats how I got all my containers running.



etc
and npm:


and in npm everything is pointing to the container’s ports directly:

less exposure this way

oh and more importantly, like i was saying, it now works:

{"tags":["redis"],"level":"info","message":"Connecting to Redis in \"standalone\" mode...","label":"feditubo.yt:443","timestamp":"2025-04-06T12:13:09.175Z"}

{"db":0,"host":"peertube_redis","port":6379,"path":null,"tags":["redis"],"level":"info","message":"Using standalone redis options","label":"feditubo.yt:443","timestamp":"2025-04-06T12:13:09.176Z"}

Now I’m also busy learning Docker, as I have my own ideas, I use [Get Started / CasaOS Wiki] (Get Started | CasaOS Wiki) it makes it easier to edit the configuration and open ports than in Portainer.