2023年9月29日 星期五

在Ubuntu 22.04 建立Node.js+MangoDB的Docker伺服主機環境

 1.首先下載並執行MangoDB docker image/container

$ sudo docker pull mongodb/mongodb-community-server

[sudo] password for user:

Using default tag: latest

latest: Pulling from mongodb/mongodb-community-server

445a6a12be2b: Pull complete

58881fc31a77: Pull complete

453d60504a24: Pull complete

7a5a2fda558f: Pull complete

aeac334df843: Pull complete

ace8b63f4bfe: Pull complete

acb03ef64e24: Pull complete

0306f57a2e92: Pull complete

4f4fb700ef54: Pull complete

2486c6c8aafa: Pull complete

Digest: sha256:7a2acbbc960ae0f8f51a102067afc846f98c4d0b27f42c828b9b81ebd5dae1ba

Status: Downloaded newer image for mongodb/mongodb-community-server:latest

docker.io/mongodb/mongodb-community-server:latest


$docker run --name mongoDB -d mongodb/mongodb-community-server

Current Mongosh Log ID: 65168b44c792982a55e6c285


$ sudo docker container ls

CONTAINER ID   IMAGE                              COMMAND                  CREATED          STATUS          PORTS                                                                                                NAMES

86abc95aa40a   mongodb/mongodb-community-server   "python3 /usr/local/…"   21 seconds ago   Up 20 seconds   27017/tcp                                                                                            mongoDB

7e886aa19c1f   openproject/community:13           "./docker/prod/entry…"   7 hours ago      Up 7 hours      5432/tcp, 0.0.0.0:1689->80/tcp, :::1689->80/tcp                                                      viaProject

26b00a8d3522   portainer/portainer                "/portainer"             3 months ago     Up 8 hours      8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/                                     tcp   portainer


$ sudo docker exec -it mongoDB mongosh

Current Mongosh Log ID: 65168b44c792982a55e6c285

Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.0.1

Using MongoDB:          7.0.1

Using Mongosh:          2.0.1


For mongosh info see: https://docs.mongodb.com/mongodb-shell/


To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).

You can opt-out by running the disableTelemetry() command.


------

   The server generated these startup warnings when booting

   2023-09-29T08:29:48.288+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem

   2023-09-29T08:29:49.046+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted

   2023-09-29T08:29:49.046+00:00: vm.max_map_count is too low

------


test> db.runCommand(

...    {

...       hello: 1

...    }

... )

{

  isWritablePrimary: true,

  topologyVersion: {

    processId: ObjectId("65168afcd1b0d08b46767dd1"),

    counter: Long("0")

  },

  maxBsonObjectSize: 16777216,

  maxMessageSizeBytes: 48000000,

  maxWriteBatchSize: 100000,

  localTime: ISODate("2023-09-29T08:31:13.551Z"),

  logicalSessionTimeoutMinutes: 30,

  connectionId: 3,

  minWireVersion: 0,

  maxWireVersion: 21,

  readOnly: false,

  ok: 1

}

test> exit


2.然後安裝Node.JS環境

沒有留言:

張貼留言