First – what is docker?
The gist is that it’s somewhat of a replacement for clunky linux virtual machines that you might use just for programming / software development. There are two main parts – Containers and Images.
A Container is like a tiny, minimalistic virtual machine. It creates a small space to run separately from everything else in your system. And you don’t need to set aside a portion of your hard-drive or bother with installing an operating system. It’s the “thing” you run your app in.
Why is this helpful? Besides saving one the trouble of setting up a virtual machine, the fact that it creates an entirely isolated system means that you can know whether or not your application includes everything it needs to run on systems that aren’t yours. I definitely had problems way back of “but it works on my computer” only to realize that some small dependency had to be installed on the recipient’s end. Though I think that’s much less common with dependency files and systems that automatically install those dependencies before running the app, this will still make it very clear whether you have set up those files correctly or not (as I know some languages, like Python, will install packages/modules system-wide if you don’t specify not to).
Images are the “instructions” of how to set up the container. They seem to be a common “starting point” for your application from which all separately-running instances are copies.
First you need to build the image using:
docker build –tag image-name path-to-image
(If you are already in the folder you want to run in docker, you can just use . instead of a full path as usual)
You need to have your docker file set up first, but running an image for the first time seems to work like this:
docker run -p clientPort:ServerPort –name process-name -d directory-name
(if you do not name it, it will create a random name for you)
You can use ‘docker ps’ to see currently running containers, and add the -a flag if you want to see containers that aren’t running as well. You can use ‘docker stop’ to stop it and ‘docker start’ to start the same one back up without having to specify port again; it’ll go run on the same port as before. It seems like you don’t use docker start on a container that doesn’t exist; you use run first to create it. If you want to delete one, you have to find the name using ‘docker ps -a’ (or just know the name if you named it yourself) and use ‘docker rm name’.