@Tirth Patel I was able to install ImageMagick by setting up my docker file to look like this:
FROM php:7.3-apache
RUN apt-get update && apt-get install -y libmagickwand-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
RUN printf "\n" | pecl install imagick
RUN docker-php-ext-enable imagick
Can you please try something similar to see if that resolves your issue?
In regards to GhostScript, install the GhostScript directly in the wwwroot folder, and whenever restarts happen, App will be loaded and in place.
Please let us know if the two above approaches resolved the issue.