When using -it (which is the same as -ì -t) the -t attaches a pseudo terminal to the container, which keeps the container running even if there is no foreground process running.
When I asked for exact commands, I was referring to something like this: docker run -d -e required_var1=configures_something -e required_var2=configures_something_else -v persist_data:/path/in/container alpine
This would allow seeing that you are trying to use a base image, which of course would immediately terminate, as it has no foreground process that keeps running. Your docker run -it command attaches a terminal to the container, which keeps the container running. Usually application images have an entrypoint script that does some sort of preparation work and then starts a foreground process that keeps the container running, until this foreground process in the container stops.
Furthermore:
- You neither install images, nor containers → you pull images into the local image cache.
- You do not run images → you create and run containers based on images.
- Each container bases on the exact image used to create it.
- A container is just a process (which can have child processes) in an isolated environment.
- If no foreground process remains running in a container, the container terminates.
As a beginner, never just describe what you do, instead share the exact commands you use, so that others can reproduce it. Typically, the problems are hidden in parts beginners judge to be irrelevant and don’t share.
I can highly recommend this free self-paced Docker training: Introduction to Containers