Configure Docker and start MongoDB-Spring introductory study notes 13

The content of the course comes from the geek time playing Spring Family Bucket, invaded and deleted , the link is as follows
https://time.geekbang.org/course/intro/100023501

The seventh day

Docker concept

What is a container

A container is an abstraction at the application layer and a standardized unit
. Unlike a virtual machine, a container does not contain operating system-related content.
Therefore, a container is lighter and easier to start and deploy than a virtual machine,
so more people choose now Create a container through Docker and start the corresponding infrastructure in the container

Docker

It is an open source engine from dotCloud

—Simplify setting up development environment

Common commands

Mirror related
• docker pull

Container related
• docker run
• docker start/stop <container name>
• docker ps <container name>

• -d, run the container in the background
• -e, set the environment variable
• --expose / -p host port: container port
• --name, specify the container name
• --link, link different containers

Configure Docker and start MongoDB

Docker

https://hub.docker.com/editions/community/docker-ce-desktop-windows/
Go to this website to download the Docker installer and install it directly. There is nothing to pay attention to.
Insert picture description here
If this error occurs, just follow the suggested website to download the linux installation package update.
Insert picture description here

After the installation is complete, first configure the domestic mirror

https://dev.aliyun.com

Start shell or cmd or terminal
input command

docker version

Display version information means the installation is normal

Test HelloWorld

Start shell or cmd or terminal
input command

docker run hello-world

The picture below is normal
Insert picture description here

MongoDB

Install mongoDB with docker command

docker pull mongo

Initialize mongoDB username and password, port information, etc.

docker run --name mongo -p 27017:27017 -v mongodata:/data/db -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=root -d mongo

Start mongo bash, enter the user name and password

C:\Users\86138>docker exec -it mongo bash
root@426a96cc4ae3:/# mongo -u root -p root

You can see that the MongoDB connection is successful.
Insert picture description here
You can enter the show dbs command to view the DB information in mongoDB

Guess you like

Origin blog.csdn.net/weixin_43596589/article/details/112819537