Why Use Docker0:45
a Laravel application locally, instead of having to install things like php and all of these extensions locally, as well as a web server, MySQL, Node, Composer, you can just install Docker to your system and use a configuration that provides all of these dependencies for you. Compared with virtual machines, Docker also has a lot less overhead as well. We don't have to spin up an entirely separate, full machine instance. Instead, a container only includes what's necessary for our application to run, using a lot less system resources. Okay, so if you don't have it installed on your system already, getting Docker is pretty straightforward. If you are on a Mac or PC, you can head on over to the Docker website and download an executable for the Docker Desktop. Run through the installation for this and it will set up everything that Docker needs.
Running a Test Container2:00
Docker Compose, which by default comes with Docker Desktop, and that we'll be using later on. Okay, so we have Docker installed. How do we use it? Well, first, let's open up a terminal. And we can use the example hello world container from Docker. docker run hello world. What this did is pull down the hello world container from the Docker hub. Docker then provisioned a container for this, executed whatever instructions were present in the Dockerfile created for it, and streamed that output to our console, which is what we see here. We can also run docker ps, which will show any active containers in our system, and you can see that there's none running here. Because the Docker methodology is that after the container runs and executes its instructions, it's brought down, but by default, not destroyed.
Managing Container Lifecycle2:48
and you can see that there's none running here. Because the Docker methodology is that after the container runs and executes its instructions, it's brought down, but by default, not destroyed. If we open up our Docker desktop window, you can see that we have an auto generated name here for the container that we just ran hello world on. It wasn't destroyed and isn't destroyed until we hit this delete button here and remove it. Alternatively, though, we can run docker run with the --rm flag. hello world again, which will remove the container completely after it runs. There's a massive amount of containers available on the Docker hub. Each container has a name, and then a variety of tags associated with it. Tags are used for versioning and to determine what specific build you want to pull into your container. If we head back into the terminal, we can do docker run --rm ubuntu:latest,
Using Tags and Commands3:40
Tags are used for versioning and to determine what specific build you want to pull into your container. If we head back into the terminal, we can do docker run --rm ubuntu:latest, which will pull the latest tagged Ubuntu container. Running this doesn't return anything, though, since the Ubuntu container doesn't have any default instructions provided for it. We can pass in our own though, by adding on after the ubuntu:latest line. So we can say docker run --rm ubuntu:latest cat /etc/os-release. After it pulls down the image and spins up the container, it'll run our pass in command, outputting the OS version information. And with that, we can see that the latest tag of the Ubuntu container is 20.04. We can also use an alternative tag too,
