So I suppose I'll just start out going over the very basics. Which so far is mostly what I know. So if you don't know much if anything about it this post is probably for you. So anyway, what is docker? You probably already know that otherwise you wouldn't be here but to sum it up it's basically a tool that allows you to install software within isolated parts of your system. Exactly how Docker does that will likely be a separate post once I learn it's internals but at least at a high level it leverage's various functions of the Linux kernel to accomplish this. If you've installed Docker on Windows it will use WSL 2 instead which under the hood I believe leverages the Hypervisor. I not all too sure about Mac but I suspect it also leverages virtualization. Anyway, that's one of the reasons why I prefer to run docker on Linux wherever possible.
With that out of the way how does one use Docker? You generally start out with an image. You can either build one yourself with a Dockerfile or pull from an existing one at an image repository. The most common one being the Docker Hub. For instance, if you're looking for a PHP image to run a local server and whatnot you can find one here. There's many different versions and configurations. Based on what you want you will have to find the right TAG. A tag of an image is basically sort of like it's name or version. For instance: 8.2.2-fpm-buster - that's the name of an image with PHP version 8.2.2 using the PHP FPM and Buster version of Debian. It all depends on your needs. If you cannot find an image in the Docker Hub which suits your needs then you will simply have to build your own from a Docker file. I will likely go over the Dockerfile and building images in a separate post.
Now as far as using/running the image, it largely depends on how the image was built. You can find that information in the documentation on the Docker Hub page or where ever it was pushed to. Sometimes a link to Github or similar. There's some flexibility here. But a large majority of the time it will involve the docker run command.
If you want detailed information for docker run then this page here is what you'll be looking for. That will go into detail about how to use it. For this post I'm just going to highlight the most common parameters ones I've used so far when running an image.
-v : When you pass the -v argument into docker run it will mount a path in your local system to a path in your docker's file system. For me this is more common when I'm trying to mount source code directories or configuration files. Sometimes for source code files you can just build and copy the files into it for instance if you're setting an environment somewhere. But for local development it's probably easier to just mount the files you are actively changing to set those changes.
-e: If you need some environment variables set this is what you'll need. Especially if your code is using custom variables for whatever reason. There's also the option to pass in an .env file with all of them at once.
--name: By default docker will generate some random name for the image as it's run, it could be confusing for logs. So I suggest that you can name it so you'll now which one is which. Especially if you use docker exec.
docker exec can be used if you need to get terminal access into your image and poke around and see what's there for debugging purposes or running backend cli commands. Details can be found here.
Anyway, I think that's a start. Next I will try to cover building images.