re: Explain containers like I'm five VIEW POST


I don't know how to explain it to a five year old but I had the exact same question as you only a couple months ago. I found and started running through tutorials. From there I dockerized everything and it has paid off.

If I were to sum up what a container is. A container is a running instance of a process or processes that is designed to be destroyed. You heard correct. Containers. Are. Immutable. They don't store data permanently and should never be treated that way. Imagine you wanted to setup a web server to start developing a web application. Ok, you need NodeJS, Git, GCC, Make, Nginx or similar, and maybe PHP. Now you have to configure them. Git clone, npm install, setup nginx.conf, run your npm start, hope it works when you come back.

Now you're done. Gotta tear it down and destroy the virtual machine lest we start mixing dependencies from other projects, losing configs, etc. I guess you could bash script or ansible the whole thing but its 2018 and we aren't animals.

Enter docker. Now you can setup an "image" with all your runtime dependencies like NodeJS and Nginx. You might be tempted to "inject" your project by using git clone during image building but again this goes against the principle of immutable containers. Instead, setup a volume VOLUME ["/usr/src/app"] and now you can start the container, telling docker to point your cloned project on the server to "/usr/src/app" inside the container docker run -v /home/name/project:/usr/src/app repo/image:version.

Now you're done again. You want to setup a new server with a new NodeJS project using the same dependencies. Literally just install docker, clone your project, run docker with -v again and thats it. Hope this helped :D

code of conduct - report abuse