Are you tired of slow website performance and seeking a solution to boost your speed? Look no further! In March 2022, I conducted a test running WordPress on Docker + OpenLiteSpeed for small websites. After a few months of monitoring, seeing that everything was working smoothly, I decided to package all the remaining large WordPress websites to run on Docker. It can revolutionize your website’s performance. Say goodbye to sluggish load times and hello to a seamless user experience. In this article, we will delve into the details of how to effectively integrate these powerful caching tools into your OpenLiteSpeed Docker environment.
However, at this time, I discovered that the default setting of OpenLiteSpeed Docker is missing Redis Cache and Memcached – two caching tools that increase processing speed as well as reduce the frequency of accessing the database for WordPress. .
Here’s how to further integrate Redis Cache and Memcached into the OpenLiteSpeed Docker system.
Table of contents
I. Install Redis Cache
1. Declare and Activate Redis
Edit files docker-compose.yml
in folder ols-docker-env
and add this paragraph at the end
redis:
image: docker.io/bitnami/redis:7.0
environment:
- ALLOW_EMPTY_PASSWORD=yes
- REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
#ports:
# - '6379:6379'
restart: always
volumes:
- 'redis:/bitnami/redis/data'
volumes:
redis:
driver: local
I add #
before the ports declaration to not open an external connection to the container running Redis. Only the OpenLiteSpeed container located in the same Docker network has access to this Redis container.
File docker-compose.yml
after editing will be similar to the following
version: '3'
services:
mysql:
image: mariadb:10.5.9
logging:
driver: none
command: --max_allowed_packet=256M
volumes:
- "./data/db:/var/lib/mysql:delegated"
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
restart: always
litespeed:
image: litespeedtech/openlitespeed:${OLS_VERSION}-${PHP_VERSION}
build: ./custom
logging:
driver: none
env_file:
- .env
volumes:
- ./lsws/conf:/usr/local/lsws/conf
- ./lsws/admin-conf:/usr/local/lsws/admin/conf
- ./bin/container:/usr/local/bin
- ./sites:/var/www/vhosts/
- ./acme:/root/.acme.sh/
- ./logs:/usr/local/lsws/logs/
ports:
- 80:80
- 443:443
- 443:443/udp
- 7080:7080
restart: always
environment:
TZ: ${TimeZone}
redis:
image: docker.io/bitnami/redis:7.0
environment:
- ALLOW_EMPTY_PASSWORD=yes
- REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
#ports:
# - '6379:6379'
restart: always
volumes:
- 'redis:/bitnami/redis/data'
volumes:
redis:
driver: local
Re-enable the system to create more Redis containers
docker-compose up -d
2. Find the IP Address of the Redis Container
We need to find out the IP Address of the Redis Container to declare in the LiteSpeed Cache plugin in the following step.
List active containers
docker ps
Results returned
[email protected]:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
29a0b87f0b19 bitnami/memcached:1 "/opt/bitnami/script…" About an hour ago Up About an hour 0.0.0.0:11211->11211/tcp, :::11211->11211/tcp ols-docker-env_memcached_1
0babcaee5704 mariadb:10.5.9 "docker-entrypoint.s…" 36 hours ago Up 36 hours 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp ols-docker-env_mysql_1
e329dffb521f litespeedtech/openlitespeed:1.7.15-lsphp74 "/entrypoint.sh" 37 hours ago Up 37 hours 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:7080->7080/tcp, :::7080->7080/tcp, 0.0.0.0:443->443/udp, :::443->443/udp ols-docker-env_litespeed_1
2822935a82d7 bitnami/redis:7.0 "/opt/bitnami/script…" 37 hours ago Up 37 hours 6379/tcp ols-docker-env_redis_1
Find the IP Address of the Redis container (ID: 2822935a82d7)
docker inspect 2822935a82d7 | grep -i IPAddress

IP Address: 172.20.0.4
3. Configure Object Cache
Access the WordPress website running on the system, access the Object Cache configuration section of the LiteSpeed Cache plugin and configure as below. Then click Save changes, if you see the line Connection Test says Passed, it means that Redis is working fine.

4. Confirm Redis Cache is running
Return to Terminal, check if Redis Cache is running with the following command
docker exec -it ols-docker-env_redis_1 redis-cli monitor
You may need to change ols-docker-env_redis_1
with the name of the running Redis Container. Use command docker ps
to check the name of the Container.
Next, access the website with a browser, if you see the screen constantly updating the parameters as shown below, it means that Redis Cache has been correctly configured and works smoothly.

II. Install Memcached
1. Declare and Activate Memcached
Similar to the above, I will declare more Memcached in the file docker-compose.yml
. After editing the file it will look like this
version: '3'
services:
mysql:
image: mariadb:10.5.9
logging:
driver: none
command: --max_allowed_packet=256M
volumes:
- "./data/db:/var/lib/mysql:delegated"
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
restart: always
litespeed:
image: litespeedtech/openlitespeed:${OLS_VERSION}-${PHP_VERSION}
build: ./custom
logging:
driver: none
env_file:
- .env
volumes:
- ./lsws/conf:/usr/local/lsws/conf
- ./lsws/admin-conf:/usr/local/lsws/admin/conf
- ./bin/container:/usr/local/bin
- ./sites:/var/www/vhosts/
- ./acme:/root/.acme.sh/
- ./logs:/usr/local/lsws/logs/
ports:
- 80:80
- 443:443
- 443:443/udp
- 7080:7080
restart: always
environment:
TZ: ${TimeZone}
memcached:
#image: launcher.gcr.io/google/memcached1
image: docker.io/bitnami/memcached:1
ports:
- '11211:11211'
Reactivate the system
docker-compose up -d
2. Find the IP Address of the Redis Container
We need to find out the IP Address of the Memcached Container to declare in the LiteSpeed Cache plugin in the following step.
List active containers
docker ps
Results returned
[email protected]:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
29a0b87f0b19 bitnami/memcached:1 "/opt/bitnami/script…" About an hour ago Up About an hour 0.0.0.0:11211->11211/tcp, :::11211->11211/tcp ols-docker-env_memcached_1
0babcaee5704 mariadb:10.5.9 "docker-entrypoint.s…" 36 hours ago Up 36 hours 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp ols-docker-env_mysql_1
e329dffb521f litespeedtech/openlitespeed:1.7.15-lsphp74 "/entrypoint.sh" 37 hours ago Up 37 hours 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:7080->7080/tcp, :::7080->7080/tcp, 0.0.0.0:443->443/udp, :::443->443/udp ols-docker-env_litespeed_1
2822935a82d7 bitnami/redis:7.0 "/opt/bitnami/script…" 37 hours ago Up 37 hours 6379/tcp ols-docker-env_redis_1
Find the IP Address of the Memcached container (ID: 29a0b87f0b19)
docker inspect 29a0b87f0b19 | grep -i IPAddress
IP Address: 172.20.0.5
3. Configure Object Cache Using Memcached
Declare as below and save, see the line Connection Test: Passed means Memcached has worked fine.

You do not need to install both Redis and Memcached tools. Because you only choose 1 of 2 to use as Object Cache for WordPress. I always choose Redis Cache.
Hope you are succesful.
If my article has been beneficial in providing valuable information and knowledge, don’t hesitate to express your gratitude through a kind message or a virtual shout-out. Your encouragement will drive me to continue sharing informative content. And, if you’re feeling generous, a donation would be greatly appreciated as it would further motivate me to keep writing. Thank you for taking the time to read!