[00:00] Head over to Docker docs and here you'll see the Docker desktop section. Click the overview and now install Docker desktop. Choose your operating system and finally the processor architecture. We can also walk to the docker.com and here you'll find the download docker desktop also choosing your operating system and the architecture. Proceed with the installation and run Docker Desktop.
[00:31] After going through the authentication and the most basic setup our Docker Desktop application is already up and running. Now we need to choose and install a Docker image for Mongo. Now a Docker image in very short is a read-only template with some instructions that provide the software which we can use to create one or more containers and the container is actually a running instance of that image that provides an isolated environment that actually runs this software. Many popular and well-maintained open-source projects have communities which maintain their Docker images and so Mongo's community has provided a whole set of images in order to install them locally and we just need to choose a tag of that image. We're going to use the latest tag.
[01:23] The first way is to run the terminal command which is going to put the mongo-latest and now we're trying to run the image and since we have never had the image before Docker needs to download the image first obviously. So there is a separate registry for the images and separate registry for the containers. Now after this image has been downloaded, Docker can run the image inside a container. So let's see how this looks in Docker Desktop. So if we take a look at images we can see that there is a Mongo image downloaded.
[02:02] We can see its size, we can run it, we can remove it, etc. And if we take a look at the containers, we will see that there is a some mongo container name, which we can also see some Multiple details over here, but there is also the information What was the image used to create this container now after running the docker? Run command we can see in the docker desktop that this image has been started, it's already running. So we can also stop it here. Now if we wanted to use Docker desktop and not the terminal we can just type mongo walk into this reference and we will see that this is the same that we've seen on the web interface and now we can just choose what is the tag that we want to install locally and that we want to run.
[02:58] So we're just going to use the container that we already have by clicking over here. However, we've got one issue with our Mongo container and that is that there is no part being exposed from this container. So right now I'm going to stop it and actually remove this container since we need slightly different setup, but still the image, the template that we are using to create containers is not yet removed. So right now I'm going to use the Docker desktop to configure our new container And here we're asked to provide additional settings. So here I can just provide a slightly different name my Mongo and here we are going to define what is our hosts port which is going to provide the services that Mongo itself is providing.
[03:49] So the port 27017 is the standard port from the Mongo service so we are just passing the same name port of the host port that Mongo is using. So let's run this one and we've been moved to the container. Here we can see the Mongo output. So going back to the containers here we have a totally new container although created from the very same image. There is a new name, new container ID obviously the same image and here we've got the port.
[04:21] So let's open this address. After opening the address localhost 27017 we can see this message it looks like you're trying to access MongoDB over HTTP on the native driver port, which essentially means this is the Mongo specific, the Mongo protocol communication and not the GUI, the graphical user interface. So if we want to play around and to type some commands, we need to have a different access. So let's use something that is maybe not the most convenient way, but still you're going to use it sooner or later, which is running the containers shell. So here we walk into the container and the exec tab and what we're going to do here is to run the mongosh command which is the mongo shell which will basically connect to our mongo database.
[05:15] Now I'm going to run the help command in order to see what are the commands. So we're going to show what are the available databases, show databases. The answer is that there is admin, config and local. We're going to use the local. So we're typing use local in order to choose what is the database that we're going to use.
[05:38] And finally, we're going to get this one from here, the show collections. So please show me what are the collections within the local database. So I could carry on typing, for instance, db.startuplog. Et cetera, et cetera, but this is not going to be the most convenient approach. Still, you're going to need this exact tab in order to run commands within the container sooner or later.