version: "3"
services:
mongodb:
image: mongo
container_name: mongodb
restart: always
ports:
- ${MONGO_BINDING_PORT}:${MONGO_PORT}
volumes:
- ${MONGO_DATA_PATH}:/data/db
env_file:
- .env
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
mongo-express:
image: mongo-express
container_name: mongo-express
restart: always
ports:
- ${MONGOEXPRESS_BINDING_PORT}:${MONGOEXPRESS_PORT}
environment:
- ME_CONFIG_MONGODB_ADMINUSERNAME=${MONGO_INITDB_ROOT_USERNAME}
- ME_CONFIG_MONGODB_ADMINPASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
- ME_CONFIG_MONGODB_URL=mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@mongodb:${MONGO_PORT}
- ME_CONFIG_BASICAUTH_USERNAME=${MONGOEXPRESS_USERNAME}
- ME_CONFIG_BASICAUTH_PASSWORD=${MONGOEXPRESS_PASSWORD}
vi ~/.env
docker pull mongo
docker images
docker-compose up -d
version: "3"
services:
redis:
container_name: redis
image: redis:7.2.4
env_file:
- .env
ports:
- ${REDIS_BINDING_PORT}:${REDIS_PORT}
volumes:
- ${REDIS_DATA_PATH}:/data
command: redis-server --requirepass ${REDIS_PASSWORD} --port ${REDIS_PORT}
레디스를 설치할때 주의할점은, 비밀번호를 꼭 설정하는 것이 좋다. 봇들이 돌아다니면서 flushall을 해버려서 key들을 다 날려버리기때문에 그렇다.
설정하다보니 왠만한 것들은 다 암호화를 해놨다.
이미지 풀하기
docker pull redis
docker-compose up -d
docker exec -it redis bash
redis-cli
ping -> pong (연결완료)
auth test -> wrong~하고 뜨면 비밀번호 설정완료
auth '${PASSWORD}' -> ok라고 뜨면 설정완료
#만들어놓은 전체 컨테이너
docker ps -a
#컨테이너 삭제
docker rm ${DOCKER_IMAGE}