DEV Community

loading...

Discussion on: Learn Docker - from the beginning, part I images and containers

Collapse
kevinhch profile image
Kevin

Hi, i have a couples of question, I thought that Docker was a tool for not having to have installed any application or tool to work, and in your tutorial you have to create a project with NPM, then I would have to node and npm installed on my local machine? Couldn't I create and generate this entire project from a container without having to install node or npm on my local machine?

Collapse
softchris profile image
Chris Noring Author

You usually use Docker for two distinct things 1) packaging, this is you describing the environment and the app code in Dockerfile and once you run docker build + docker run, you have a running instance that's like a black box. 2) development, you can use it for development. The scenario I've seen most is that developers install all they need on a local machine, then they create a mount point between local app files and a place in the container, once it's up and running, this allows you to change files locally and have that change reflected in the container. The second scenario you are referring to here is doing everything in a container. You would then create a container, attach to it and do local dev in there, it's the less used scenario, cause you would still need to find a way to persist what you do (app code changes) to a mount point on your drive, in case you need to power down and power up the container

Collapse
kevinhch profile image
Kevin

ok, but if i want to create an application with node and react, I installed that on my local machine, in this point, I don't need a container because I have this programs in my local machine, and I share this project, the people just need to exec an npm start to install the packages, docker has a docker hub right? this is not like github? I mean, if I create a container, can I take a snapshot of this container and did a docker push origin to my docker repo to pull on another PC?

Thread Thread
softchris profile image
Chris Noring Author

normally you wouldn't share a container but rather point ppl to a GitHub repo where app code lives, together with a Dockerfile.. a container is a running instance of your app.. Then to restore it you would just to docker build + docker run on the Dockerfile in your GitHub repo

Thread Thread
softchris profile image
Chris Noring Author

as for using Docker Hub, that's used to share Docker images, not containers.. so if you have a Dockerfile you are happy with, you start with an ios image, you add scripts to install things on it you can then build an image from the Dockerfile and push it to Docker Hub, then others can use that image.. I mean it all depends on what you want to achieve.. if you want to share app code, I would say it's GitHub, if its a certain base image + installing things like brew, node.js then I suggest create an image from that and push DockerHub

Thread Thread
kevinhch profile image
Kevin

ok thanks, I need to keep clean my local machine, and I will find the method to develop all my applications on containers. Thanks again man :)