Sarath, I used to have the same problem. 16 GB may not be enough if you're using Windows.
To solve it, I had to restart my laptop and close all applications I didn't need (Email, Teams, VSCode, Chrome Tabs, OneDrive) as much as possible. Start the Docker container and try publishing your app. In my case, the container used more than 8 GB, and I didn't have more RAM because other apps were running.
------------------------------
Maycon Belfort
Consultant
BPD Zenith
Melbourne
Australia
------------------------------