So, what's a typical workflow for running a program (or programs) inside a container?
First, you'd specify the setup of your environment and application inside a Dockerfile, where each line is a step in the setup process:
FROM node:8
RUN yarn
RUN yarn run build
CMD node dist/index.js
Then, you’d actually carry out the steps specified in the Dockerfile to generate an image. An image is a static, immutable file that contains the executable code of our application. The image is self-contained and includes our application code, as well as all of its dependencies such as system libraries and tools.
Then, you'd use Docker to run the image. A running instance of an image is a container. Your application runs inside that container.
By analogy, a Dockerfile contains the instructions on assembling an electric motor. You follow the instructions to generate the motor (image), and you can add electricity to the motor to make it run (container).
The only difference between Docker and our analogy is that many Docker containers can run on top of the same Docker image.