There is an upcoming feature in Docker which allows building containers the
way you described.
It's called multi-stage builds:
It's available in beta versions only for now.
Btw, I'm using https://www.notion.so/ for taking notes while I'm
researching or developing something.
It's like a wiki but real-time collaborative and allows publicly sharing
I highly recommend you copy paste your commands into such a tool OR
at least into a text file as you are developing something, then it's a lot
to turn it into an actual article / blog post / wikipage.
As a middle ground between Notion and a plain text file is creating a
which you can store on Dropbox, Google Drive, GitLab, GitHub for later
The secret to create a Markdown file effortlessly is to use the
https://typora.io/ editor, because it is NOT a dual-pane editor.
It actually shows you the content you typed in a nicely rendered format,
EXCEPT around your cursor, where it reveals the underlying markdown
and allows direct, plain text interaction with them.
I know these sound nuances, but such details can really affect our psyche
make the difference between creating and liberating knowledge or
procrastinating over it.