Make Your Nextcloud Docker Instance Fly: Add Redis Caching

There’s an array of tutorials online for boosting your Nextcloud Docker instance performance; some lead to dead ends, others are convoluted. Here’s a more straightforward approach.

Edit Your Compose File

Two edits are required:

  1. Add a link between the app container and the Redis container to enable communication.
  2. Include a Redis container in our stack.
version: '3'
      - redis
    image: redis:alpine
    restart: always
    command: redis-server --requirepass goodpassword

Note: While not thoroughly documented, it’s crucial to set a password for NC to accept your cache.

Edit Your config.php File

Utilize Redis for both file locking and local caching. Running APCu for caching while still running Redis for file locking is redundant. Moreover, Redis offers superior performance.

  'memcache.local' => '\OC\Memcache\Redis',
  'filelocking.enabled' => true,
  'memcache.locking' => '\OC\Memcache\Redis',
  'redis' => array(
     'host' => 'redis',
     'port' => 6379,
     'timeout' => 0.0,
     'password' => 'goodpassword',


A simple docker-compose up -d should do the trick!

You should now notice a significant performance improvement and reduced system load on frequently accessed objects in the NC Photos gallery.

nc_all_pass In the Nextcloud Administration settings panel, you should see an “All checks passed” message.