No, it’s not possible to change the Dockerfile of a running container directly as the Dockerfile is just a script that is used to create a Docker image. The running container is an instance of the Docker image.
However, you can do changes on the Dockerfile and build a new image, and then replace the running container with a new container from the new image. Also, you can enter a running container and make changes, but these changes will be lost once the container is removed unless you commit those changes to a new image.
Below is the general process to make changes if you have a need:
1. Stop the running container
2. Make changes to the Dockerfile
3. Build a new image using the Dockerfile
4. Start a new container using the new Docker image
It’s important to note that this would hinder the repeatability and traceability that Docker images provide. If your application requires modifications, they should be made during the building phase of an image (Dockerfile) or implemented as a persistent volume.