Noob question - why do I have to rebuild image when I change project code?

Hi, everyone

I’m learning Docker and working my way through the Getting Started. The following screenshot has me stumped and has me wondering whether I’ve misunderstood what an image is:

I had thought an image was just a set of instructions to set up a runtime - programming languages, versions, deps etc. NOT the project content itself (i.e. what you store in Github).

So if I’m right about that, and images are separate from content, why do I need to rebuild the image if I make content changes?

Thanks in advance


It really depends on the project, but I would put the application/web data in the image, so you’re able to use the images as version control for your application.

But can you on container start, pull the latest version from git, instead of bundling your application in the image? sure thing, if thats what you want :slight_smile:

Thanks, Martin. So if I understand you right the image I push to Hub contians my actual project content? That is a revelation to me; I thought an image was just runtime setup.

So in terms of workflow, if I’m working locally, and I’m making high-frequency writes to my files, I have to keep rebuilding the image with each file write, is that right?

Again, it really depends on what you want and what you’re building, but i would do it that way yes, to have version control.

And yes you would do that, BUT, a feature on docker hub is that you can point your image on docker hub, to a github repo, so everytime there is changes it auto builds your image from the dockerfile and releases a new version.

1 Like

Thanks for asking this, I was also wondering about it.