Newbie help on container data

I’m learning docker for all of about 8 hours and am confused about something.

If I run a simple application in Ubuntu that all runs in a single directory, then convert this application into a container, and all data and config is stored in that same container then what happens if I lose the hardware and pull my docker container onto new hardware as any changes since creation will be lost won’t they? What am I missing?

Can I create an automatic take to push the container back out like a daily backup and then just pull the latest version on boot or……

Hi

Yes that container is gone.
What you want to do is:

  1. create an image (preferably via Dockerfile) with all the scripts/apt command that you need
  2. push that image to docker hub / take backup of that image (docker save | Docker Documentation)
  3. start a container from that image, and make NO manual changes to that container.
  4. if you want to save data from that container, map a local folder into the container (Use volumes | Docker Documentation) and take backup of that local folder

hope that makes sense :slight_smile:

Great thank you. I’ll give that a go tomorrow. Thanks for your help.