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:
E: Sub-process /usr/bin/dpkg returned an error code (1)

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