Docker - get started

ref: https://docs.docker.com/machine/get-started/ 

Docker - get started

Docker - get started

 Docker - get started

Docker - get started

 [Narrator] To get started with MongoDB, we first have to use Docker to download and run a container for it. Make sure that your Docker daemon is running. You can do that by simply clicking here on the Docker icon, and you see that Docker is running here. And then, open the terminal. And here, we type docker pull mongo. And this will pull down the MongoDB image from Docker Hub.

Next, we start a new container by typing docker run --name. And we will call this container mongodb, and now we add some port configuration. I will explain it in a second. So, first I type it 37017, column 27017.

And this will map the default port 27017 to 37017 on localhost. Next, I add a -d. This will make sure that the container will be detached. This means it runs in the background. And then, we also have to add the image that we want to use to create this container. Again, your mileage might slightly vary depending on the operating system you are on.

Basically it's always the same. But if you run into problems, please look into the documentation of Docker for your operating system. Now hit Return, and our MongoDB container is already running. We can test this by typing docker ps. And here we see this MongoDB container. It might happen that this container stops for some reason or you restart your system and Docker is not running anymore.

So to restart this container later then, you can always run docker start mongodb and this will start the container again. When working with databases, it's always a good idea to also havesome graphical interface to it. And we will install one for MongoDB now. I choose to use Robo 3T for that. So I open the browser, and I type robo 3t.

And I take the first result here. And I select Download Robo 3T, right here, download again.And as you see, there are versions for Windows and Linux as well. I download the Macintosh installer here and I run it. And I now I drag this icon into my Applications folder. So let's open it now. I simply select Search here and type robo 3t, and here we go.

Now we have to configure our connection to our database server. For that, I click on Create.And let's call it simply Local Mongodb. And for that, we connect to localhost and to our port 37017. Let's test that, and it works well.

So I can save this connection, and then I can double-click on it to open it. And on your left menubar, you should see some system tables already on your local database here. Now, MongoDB is already running on our system, and this was quite easy. Of course, for production deployment, setting of MongoDB is way more challenging. There are a lot of configuration options like security, storage engines, replications.

And you might even want to consider tweaking your filesystem and kernel settings to make MongoDB run smoothly under high load. For our sample project though, this setup will fully suffice.

 

Stop & start mongodb

docker start mongodb (or container id)

docker stop mongodb

then check docker ps

[it's gone]

 

connect to mongo for robo 3T

Docker - get started

 

hostname: 192.168.99.100

port: 37017

robo 3t 

Docker - get started

mongo compass

Docker - get started

https://forums.docker.com/t/how-to-use-localhost-instead-of-192-168-99-100/54098

 

 

 

 

 

 

 

 

上一篇:a-second-operation-started-on-this-context-before-a-previous-operation-completed


下一篇:Wamp win10 1077error