Persist changes to an app running in a container

Hello. First time docker user seeking help to configure an app (Apache NiFi) that I have running in a Docker container on an AWS EC2 instance. I must make changes to the config files used to start the app. I need to learn how to do two things:

  1. make changes in config files for the app that I need to reapply every time I stop/start that results in a new container instance. How can i persist these changes and apply them at container initialization?

  2. there are certain changes to standard configuration for the app recommended to improve its performance. For example, the placement of the four key repositories used by the app on different disk devices. Docker installs them in one location in the container. Ideally each should be on its own mounted device.
    I can alter the location parameter in a config file called for each repo location. Assuming I can persist such changes so they are made to the container each time I stop/start a container running nifi, what must I do to permit the app in the container to read/write to the external repo location?

Any help is much appreciated.

Also, my apologies if this is not the correct place to post this question. I’m still trying to get the hang of the Docker forums.

Please share the exact command, or if docker compose was used the compose file, you used to start the container.

Normally configuration data is stored in volumes, either by binding a folder/file from the host file system into the container file system or by using a named volume.

Sorry for the delayed reply. I had some trouble getting back in with my userid, but that is resolved.

The command I use is this:
docker run --name nifi -p 8443:8443 -e -d apache/nifi:latest

You will want to use a volume:

You can either bind a host folder (or even single file) as volume into a container path, or you can use a named volume to persist. Since you are on AWS, you could also create a named volume that points to an EFS share.

Though, I would highly recommend to start using docker compose and use a compose file to store your container configuration. On long term, it will save a lot of time and helps keeping the container configuration repeatable.