-
[Docker, MongoDB] 도커에 올렸더니 Authentication failed🩸 삽질의 추억 2024. 4. 14. 14:51728x90
상황: docker compose up(혹은 run) 후, swagger 까지는 잘 들어가지는데 execute 를 하면 Authenication failed 가 뜨는 경우이다.
+ 로컬에선 문제 없었음
해결
// docker-compose.ymlversion: '3.8'
services:
mongodb:
(중략)
environment:
- MONGO_INITDB_DATABASE=chatDB
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=root
app:
(중략)
environment:
- SPRING_DATA_MONGODB_URI=mongodb://root:root@mongodb:27017/chatDB?authSource=admin
// application.yml (과 비교하면서 docker-compose.yml 작성해야함!)spring:
data:
mongodb:
host: mongodb
port: 27017
authentication-database: admin
username: root
password: root
database: chatDB삽질한 이유
1. MONGO_INITDB_DATABASE 를 설정하지 않았다.
2. SPRING_DATA_MONGODB_URI 를 설정하지 않았다.
대응되는 설정은 색상으로 표시함
728x90'🩸 삽질의 추억' 카테고리의 다른 글
[Spring Boot] swagger 로 테스트 중, body를 넘기는데 null 값이 들어왔다고 함 (0) 2024.04.17 [NCP, Docker] ssh 서버에 docker compose up 으로 Spring Boot + MongoDB 한번에 run 하기 (0) 2024.04.14 [Docker+원격서버] 플랫폼 호환- 옵션 부여/compose.yml 에 작성 (0) 2024.04.14 [Docker] 배포 후, “사이트에 연결할 수 없음” (0) 2024.04.14 [CORS, Spring Boot] WebMvcConfigurer 설정 후에도 access-control-allow-headers 에러 (0) 2024.04.14