Ok, so I didn't understand either, then I left my pc, went to do other things, and upon my return, it clicked :D
You download a docker image file. docker pull *image-name*
will just pull the image from docker hub without running it.
Now, you use docker run, and give it a name (e.g. newWebServer).
docker run -d -p 8080:8080 -v volume --name newWebServer image-name/version
You perhaps only need docker run --name *name* *image*
, but the other stuff will become useful quickly.
-d
(detached) - means the container will exit when the root process used to run the container exits.
-p
(port) - specify the container port and the host port. Kind of the internal and external port. The internal one being the port the container uses, and the external one is the port you use outside of it and probably the one you need to put in your web browser if that's how you access your app.
--name
(what you want to call this instance of the container) - you could have several instances of the same container all with different names, which is useful when you're trying to test something.
image-name/version
is the actual image you want to create the container from. You can see a list of all the images on your system with docker images -a
. You may have more than one version, so make sure you choose the correct one/tag.
-v
(volume) - perhaps not needed initially, but soon you'll want to persist data after your container exits.
OK. So now, docker run just created a container from your image. If it isn't running, you can now start it with it's name:
docker start newWebServer
You can check all your containers (they may or may not be running) with
docker ps -a
You can stop and start them (or pause them) with their name or the container id (or just the first few characters of it) from the CONTAINER ID column e.g:
docker stop newWebServer
docker start c3028a89462c
And list all your images, with
docker images -a
In a nutshell, download an image; docker run creates a container from it; start it with docker start (name or container id); stop it with docker stop (name or container id).
docker ps -a
to see all containers in this case. – Irritative