How Programs Run
Every container is just a program that is running — what we call a process. To really understand Docker you need a small handful of everyday words that describe how any program runs: what a process is, where its text output goes (stdout, and errors go to stderr), how it reports success or failure wh
A running program is like a worker at a desk: settings arrive in their inbox (environment variables); they write normal notes on a shared whiteboard everyone can read (stdout) and errors on a separate red board (stderr); messages reach them through a numbered mail-slot (a port); you can tap their shoulder to ask them to wrap up (a signal); and when they leave they hand in a slip saying 'all good' (0) or 'there was a problem' (non-zero) — the exit code.
- process
- A program that is currently running. The file on disk is just waiting code; when you start it, the active instance in memory is called a process. A container is essentially one such process.
- stdout / stderr
- Two 'channels' a program writes text to. stdout (standard output) is the normal output channel — the things the program wants you to see. stderr is a separate channel for errors, so you can keep trouble messages apart from normal output.
- port
- A number that acts as a 'numbered door' through which other programs or users reach a running program. For example, a web server usually listens on port 80 or 8080, like a numbered mail-slot everyone knows to use.
- signal
- A short message the operating system sends to a program to ask it something — most often 'please stop'. When you press Ctrl-C in the terminal, such a stop signal is sent, and a well-behaved program shuts down cleanly.
- environment variable
- A name=value setting handed to a program when it starts, without changing its code. This is how the same program gets different settings in each place — for example a password or a port number — without touching the program itself.