Container Remain Running for postgres and redis when no process running on it

As taught in docker lecture when we run a container example- using image postgres it will pull the image from docker hub and run container and exited if no process running on it. But in lecture of docker compose–>Demo-Example voting application when redis and postgres container run using docker run command they remain in running state also no process is running on that?

Those containers have applications running. For example when you start a redis container, redis will run.

so if i run a container of mysql image it will also be running?

Yes when you run the mysql container with the right options then mysql will be running.

I see in your first post you refer to postgres. This needs env vars set - it is always best to run docker containers in the foreground first to see output until you are comfortable in how they work:

$ docker run postgres
Error: Database is uninitialized and superuser password is not specified.
       You must specify POSTGRES_PASSWORD to a non-empty value for the
       superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".

       You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
       connections without a password. This is *not* recommended.

       See PostgreSQL documentation about "trust":
       https://www.postgresql.org/docs/current/auth-trust.html