๋ฐ์ํ
๐ก ๋ณธ ๋ฌธ์๋ 'Docker๋ฅผ ์ด์ฉํ์ฌ MongoDB ์๋ฒ ๋์ฐ๊ธฐ (feat. mongo-express, Robo 3T)'์ ๋ํด ์ ๋ฆฌํด๋์ ๊ธ์ ๋๋ค.
Docker๋ฅผ ์ด์ฉํ์ฌ MongoDB ์๋ฒ ๋์ฐ๊ณ ์ด์ ์ ์ํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์ ๋ฆฌํ์์ผ๋ ์ฐธ๊ณ ํ์๊ธฐ ๋ฐ๋๋๋ค.
1. Mongo DB ํ๋ก์ ํธ ์ค์
1.1 mongodb ๋๋ ํฐ๋ฆฌ ์์ฑ ๋ฐ ๋๋ ํ ๋ฆฌ ๊ถํ ๋ณ๊ฒฝ
% mkdir mongodb
% chown 999:999 mongodb
1.2 docker-compose.yml
# docker-compose.yml
version: "3.8"
services:
mongo:
image: mongo:5.0
container_name: mongo
env_file:
- .env
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
restart: unless-stopped
ports:
- "27017:27017"
volumes:
- ./database/db:/data/db # mongodb ๋ฐ์ดํฐ ์ ์ฅ
- ./database/dev.archive:/Databases/dev.archive
- ./database/production:/Databases/production
networks:
- mongodb
mongo-express:
image: mongo-express
container_name: mexpress
env_file:
- .env
environment:
- ME_CONFIG_MONGODB_ADMINUSERNAME=${MONGO_INITDB_ROOT_USERNAME} # mongodb ์ปจํ
์ด๋์ root ๊ณ์
- ME_CONFIG_MONGODB_ADMINPASSWORD=${MONGO_INITDB_ROOT_PASSWORD} # mongodb ์ปจํ
์ด๋์ root ๋น๋ฐ๋ฒํธ
- ME_CONFIG_MONGODB_URL=mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@mongo:27017/?authSource=admin
- ME_CONFIG_BASICAUTH_USERNAME=${MONGOEXPRESS_USERNAME} # mongo-express ์ฌ์ฉ์ ๊ณ์
- ME_CONFIG_BASICAUTH_PASSWORD=${MONGOEXPRESS_PASSWORD} # mongo-express ์ฌ์ฉ์ ๋น๋ฐ๋ฒํธ
restart: unless-stopped
ports:
- "8081:8081"
networks:
- mongodb
networks:
mongodb:
driver: bridge
1.3 .env
#####MONGODB
MONGO_INITDB_ROOT_USERNAME=root
MONGO_INITDB_ROOT_PASSWORD=password
#####MONGOEXPRESS
MONGOEXPRESS_LOGIN=mexpress
MONGOEXPRESS_PASSWORD=mexpress
1.4 docker-compose ๋์ฐ๊ธฐ
% docker-compose up -d
% docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------
mexpress tini -- /docker-entrypoint ... Up 0.0.0.0:8081->8081/tcp
mongo docker-entrypoint.sh mongod Up 0.0.0.0:27017->27017/tcp
2. Mongo DB ์ ์
2.1 mongo-express ์ด์ฉ
docker-compose๋ก ๋์ด mongo-express์ ์ ์ํ๊ธฐ ์ํด์๋ ์ธํฐ๋ท URL์ ๋ค์๊ณผ ๊ฐ์ด ์ ๋ ฅํ๋ค.
http://<ip>:8081/
์ฐธ๊ณ
- [dockerhub] mongo-express: https://hub.docker.com/_/mongo-express
- [github] mongo-express: https://github.com/mongo-express/mongo-express
- [Blog] Containerize MongoDB and Mongo Express using Docker Containers: https://devops.tutorials24x7.com/blog/containerize-mongodb-and-mongo-express-using-docker-containers
- mongodb, mongo-express ๋์ปค ์ปจํ ์ด๋ ์ฌ๋ฆฌ๊ธฐ: https://sangchul.kr/318
๋ฐ์ํ
'Study: DeveloperTools(DevTool) > DevTool: NoSQL(Elastic, Mongo)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[NoSQL] MongoDB์ ์ ์ํ๊ธฐ (mongo-express, Robo 3T, VSCode) (0) | 2023.01.16 |
---|---|
[NoSQL] MongoDB C++ ํ๊ฒฝ ์ค์ ํ๊ธฐ(feat. linux mongocxx driver) (0) | 2023.01.12 |
[NoSQL] MongoDB Geospatial ์ฟผ๋ฆฌ: GeoJSON ๋ฐ์ดํฐ ํ์ฉํ๊ธฐ (0) | 2022.11.20 |
[NoSQL] Apache Cassandra ์ ๋ฆฌ: NoSQL Column-Family DB (0) | 2022.11.17 |
[NoSQL] Redis(vs Memcached) ์ ๋ฆฌ: NoSQL Key-value DB (0) | 2022.11.16 |