- Spring 5.0 By Example
- Claudio Eduardo de Oliveira
- 348字
- 2021-06-24 19:17:39
Preparing MongoDB
Let's create our MongoDB container. We will use the official image provided by the Docker Hub.
First, we need to pull the image:
docker pull mongo:3.4.10
Then, we will see the Docker Engine downloading the image contents.
To create an isolation from our containers, we will create a separated network for our application and database. The network should use the bridge driver to allow the container communications.
Let's create a docker network:
docker network create cms-application
The command output should be an ID of a created network. Your ID will probably be different compared to mine:

To check if the network was created successfully, the docker network ls command can help us.
We will start our MongoDB. The network should be cms-application, but we will map the database port to a host port. For debugging purposes, we will connect a client to a running database, but please don't do this in a non-development environment.
To start, type the following command:
docker run -d --name mongodb --net cms-application -p 27017:27017 mongo:3.4.10
The output will be a hash which represents the ID of the container.
The parameter instructions are:
- -d: This instructs Docker to run the container in a background mode
- --name: The container name; it will be a kind of hostname in our network
- --net: The network where the container will be attached
- -p: The host port and container port, which will be mapped to a container on a host interface
Now, we have a pretty standard MongoDB instance running on our machines, and we can start to add a persistence in our CMS application. We will do that soon.
- Building a RESTful Web Service with Spring
- Visual FoxPro 程序設計
- Python Network Programming Cookbook(Second Edition)
- Mastering Android Game Development
- 劍指大數據:企業級數據倉庫項目實戰(在線教育版)
- Python High Performance Programming
- Node Cookbook(Second Edition)
- 從零開始學C#
- 現代C++編程實戰:132個核心技巧示例(原書第2版)
- QGIS 2 Cookbook
- 自學Python:編程基礎、科學計算及數據分析(第2版)
- Mastering Gephi Network Visualization
- 軟件測試分析與實踐
- 深入理解Java虛擬機:JVM高級特性與最佳實踐
- R統計應用開發實戰