New to docker, not quite there with understanding it

Trying to get a better understanding on Docker. Some of the basic questions I am unsure about.

  • I can create an environment as an image and then run it in a container?
  • If I add to the container and then stop it, my code vanishes?
  • If I update an image, it the original image plus + my code but as a new image?
  • If I add a rails to a ruby image, then save it as a new image I can use the new “rails” image to create containers and in turn create a rails app? But if I do stop the container it will wipe my app?
  • Do I continue using github? I am guessing it’s just for the environment only?

Ideally I would like to create a rails 5 image and create my apps in those but have them easily stick around. I hope my colleagues can download my app and run it in the same image?

I have more questions but I guess I can start here.

Sorry for the beginner questions!

All of this is correct.

You can (and should) build an image containing your app. This could, if you like, be built on top of your shared rails image. Look up the docker build command and the Dockerfile system (and if you’ve found docker commit or docker export, don’t use those).

I don’t really understand the question. In addition to using Github for source control for your application, you can also store the Dockerfile in the repository. If you have a side repository of automation scripts, you should run git clone in a wrapper script, not in the Dockerfile.

My intention was to use the same docker image for many students to get their environment up and running quickly on any platform (Mac/Linux/PC) by installing Docker and then downloading the same image.

Then they would use the image to create a container where they could generate a rails app and upload their progress to github.

My concern is if they stop the process they will lose the files that they have created in the container…?

Also: thanks for your reply :slight_smile:

If you don’t delete the container ,you won’t lost the files that you create. A better way ,you can use Volume to mount the host directory to container ,save the files in the volume directory,even though,you delete the container ,you won’t lost the files.

Volume? I’ve not seen documentation about this yet…?


Check this URL

At first observation it looks overly complicated…

I’m assuming you create an image file where you would store your files and then use the container to mount it as a volume?