Steps to understanding docker?

Trying to wrap my head around docker so any advice is most appreciated.

  1. Install docker
  2. Write a docker file that has commands that will install an image, e.g. ubuntu, step into that image and install any ubuntu updates I may want.
  3. Install using the docker file any extra environment files I might need say a language (ruby, node, php).
  4. Install git from the docker file and have that download a project into the environment
  5. Create a config file so that the container ports are open to the ports I want to use (server)
  6. Run the docker file which will run the image and any cli commands like starting the server, getting data from github etc.
  7. save docker container as new image?

Hoping someone can clarify it is used in this way and add anything I should do or have missed.

Other questions are - if I am sending this to a host, is the host going to take the container or the contents of the container aka ubuntu and just run that? If it takes the container does it mean the host has pre-installed docker and is setup for it (as another layer).

1 Like

That is pretty much the way it works, although the commands are different. Once you have it all built up the way you want it and have it all set in the dockerfile, you would use docker build to create one single image out of all the pieces. So you wouldn’t have to redo it all to get it setup again. As long as you don’t remove that image, you can remove all the pieces you pulled down to free up some space. As for the second question as long as it uses that same created image it would get everything the first machine had. I am uncertain of what you mean by “sending it to a host.” If you upload it to the Docker Store, then once the new machine has docker installed, it could pull that single image down and use it, yes. If it has proprietary info in it the you would have to use your free private repository. Or. if you need more than one, go to this web page… https://www.docker.com/pricing#/pricing_cloud … their pretty reasonable. (and No, I don’t work for them, I just wish I did :wink: )

1 Like

Thanks for the answer, I’m starting to get the hang of how it all works. Thanks for the link :slight_smile:

1 Like

My bad… the images do not combine to a single one, they just look like they do when running. To put it on a new machine, just copy the dockerfile to it and then do a “docker build dockerfile” and it will install every thing to the new machine. There is never a ‘single’ image, just a combination that looks that way.