You can try use command:
command:
services: my-redis: image: redis:6.2-alpine ports: - "6379:6379" networks: - my-service command: bash -c "sysctl vm.overcommit_memory=1 && redis-server --save 20 1 --loglevel warning"