While installing cuda toolkit inside a existing docker image gives error

I have an existing docker image in which i need to install cuda toolkits and cudnn.
But while installing cuda toolkit itself it’s not installing.
OS : ubuntu 18.04

Errors were encountered while processing:
 /tmp/apt-dpkg-install-w2f778/030-nvidia-compute-utils-515_515.48.07-0ubuntu1_amd64.deb
 /tmp/apt-dpkg-install-w2f778/035-nvidia-utils-515_515.48.07-0ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

It would be great someone can guide how to do this properly.