Imagine you are the manager of a software company and you just bought a brand new server. Just the hardware.
Think of Dockerfile as a set of instructions you would tell your system adminstrator what to install on this brand new server. For example:
- We need a Debian linux
- add an apache web server
- we need postgresql as well
- install midnight commander
- when all done, copy all *.php, *.jpg, etc. files of our project into the webroot of the webserver (
/var/www)
By contrast, think of docker-compose.yml as a set of instructions you would tell your system administrator how the server can interact with the rest of the world. For example,
- it has access to a shared folder from another computer,
- it's port 80 is the same as the port 8000 of the host computer,
- and so on.
(This is not a precise explanation but good enough to start with.)