Docker deploy on specific container

I have an issue, i want to know how can i do that ?

I should have single source code and I should be running multiple containers on basis of that single source code. e.g staging, development, production

I will be doing changes on my local machine and when I am done testing on my local machine, and when I am satisfied, i should choose on which environment i want to deploy

e.g I only want to deploy on staging server, not on production.

E.g If i make changes on my source code files , it should not affect my containers on production.

How can i achieve that with a single source code file for my multiple runnig containers on different environments.

I’m afraid there’s no general answer, that depends a lot on the deployment mechanism you use.

For the containers themselves it is important that environment-specific configuration is not part of a container image. The configuration should be provided by other means, e.g. environment variables or configuration files mounted into the container. That way you can use the same container images in different environments, and just provide the configuration through whatever you use to manage the containers (e.g. a Kubernetes Pod definition, or Docker Compose file).