Setting-memory-swap-in-docker-compose-giving-error

I am new to docker setup, I am running a job in AWS Ubuntu server. It is a long-running job and requires some memory, my system has 4GB physical memory, I created an 8GB swap memory(as per this link https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-18-04/). I would like my docker container to use the swap memory, so I tried to configure it in my docker-compose file like follows. But its throwing error like

"ERROR: The Compose file ‘./docker-compose.yml’ is invalid because: services.moonlight.deploy.resources.reservations value Additional properties are not allowed (‘memory-swap’ was unexpected)"

version: '3'
services:
  moonlight:
    build: ./
    restart: unless-stopped
    hostname: moonlight
    deploy:
             resources:
               limits:
                 memory: 4000M
               reservations:
                 memory-swap: 8000M
    ports:
      - "80:3001"

Your help is much appreciated.