inflearn logo
강의

Khóa học

Chia sẻ kiến thức

Docker dễ dàng dành cho nhà phát triển

Cấu hình ứng dụng lá

Docker 백앤드 컨테이너 실행시 오류

430

steven

1 câu hỏi đã được viết

1

안녕하세요, 강의 6-3을 듣다가 막히는 부분이 있어 질문드립니다.

 

postgres container를 잘 실행하고 백엔드 컨테이너를 docker run -d -p 80:80 --network leafy-network --name leafy-front devwikirepo/leafy-frontend:1.0.0 명령어를 통해 실행하였습니다. 그런데 이후에 log를 보면 아래와 같은 문구들이 나오면서, 에러가 발생했다고 나옵니다.

Screenshot 2025-02-28 at 9.40.46 PM.png

(글씨가 너무 작아서, 에러 부분은 아래와 같습니다)

2025-02-28 12:36:54.708 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 526 ms

2025-02-28 12:36:54.731 ERROR 1 --- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processorMetrics' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/SystemMetricsAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.micrometer.core.instrument.binder.system.ProcessorMetrics]: Factory method 'processorMetrics' threw exception; nested exception is java.lang.NullPointerException

2025-02-28 12:36:54.740 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]

2025-02-28 12:36:54.743 WARN 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat

2025-02-28 12:36:54.749 INFO 1 --- [ main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2025-02-28 12:36:54.757 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed

 

docker ps -a를 해보면 아래와 같이 로그가 나옵니다.

Screenshot 2025-02-28 at 9.42.38 PM.png

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

df36a2b0896f devwikirepo/leafy-backend:1.0.0 "java -jar leafy.jar" 52 seconds ago Exited (1) 50 seconds ago leafy

9e9ee5a82c36 devwikirepo/leafy-postgres:1.0.0 "docker-entrypoint.s…" 27 minutes ago Up 27 minutes 5432/tcp leafy-postgres\

 

혹시 어떤 오류이고, 어떻게 해결하면 좋을까요? 감사합니다.

docker 가상화 ci/cd docker-compose github-actions docker-volume docker-image container

Câu trả lời 5

0

tmd8633

https://www.inflearn.com/community/questions/1538955/docker-leafy-backend-%EC%8B%A4%ED%96%89%EC%98%A4%EB%A5%98

 

한번 해보셔요

0

daintree

steven님 안녕하세요. 데브위키입니다.

가장먼저 시도해볼 수 있는 것은 컨테이너를 삭제한 후 다시 실행해 보는 것입니다.

기존 컨테이너 삭제

docker rm -f leafy

새 컨테이너 실행

docker run -d -p 8080:8080 -e DB_URL=leafy-postgres --network leafy-network --name leafy devwikirepo/leafy-backend:1.0.0

 

만약 문제가 동일할 경우, 데이터베이스 컨테이너가 잘 실행 중인지 확인이 필요합니다.

docker logs leafy-postgres

아래와 같이 로그가 나오는지 확인해보시겠어요?

2025-03-03 14:55:37.562 GMT [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2025-03-03 14:55:37.562 GMT [1] LOG:  listening on IPv6 address "::", port 5432
2025-03-03 14:55:37.563 GMT [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2025-03-03 14:55:37.566 GMT [65] LOG:  database system was shut down at 2025-03-03 14:55:37 GMT
2025-03-03 14:55:37.572 GMT [1] LOG:  database system is ready to accept connections

0

gouyeonch

저도 같은 에러가 뜹니다 ㅠ

0

steven

참고로 docker inspect leafy-postgres | grep -A 2 "Networks"를 실행하면, 아래가 출력됩니다.

"Networks": {

"leafy-network": {

"IPAMConfig": null,

0

steven

6-5에서 springboot연결시에도 동일한 오류가 발생하네요ㅜㅜ

0

communityai8509

안녕하세요, 인프런 AI 인턴입니다.

steven님, Docker를 사용하여 백엔드 컨테이너를 실행하는 동안 발생한 오류에 대해 질문해주셨군요. 로그 메시지를 보면 Spring Boot 애플리케이션이 시작되지 못하고 UnsatisfiedDependencyException과 연관된 오류로 인해 Web Server인 Tomcat이 시작되지 않고 있음을 알 수 있습니다. 이러한 유형의 오류는 주로 의존성 주입을 수행하는 과정에서 필요한 빈(bean)이 존재하지 않거나 초기화가 실패해서 발생합니다.

해결책에 대해 몇 가지 제안 드리겠습니다:

  1. 의존성 확인:

    • UnsatisfiedDependencyException은 특정 의존성이 맞지 않거나 누락되었을 때 발생할 수 있습니다. application.properties 또는 application.yml 파일에서 의존성과 관련된 설정이 제대로 되어 있는지 확인해 주세요.
  2. 환경 변수 및 설정 확인:

    • 환경 변수나 application.properties 설정 파일에서 의존성과 관련된 설정이 잘못되어 있으면 오류가 발생할 수 있습니다. 특히 DB와 관련된 설정(DB URL, 사용자명, 비밀번호 등)을 확인해보세요.
  3. 필수 Bean 확인:

    • simpleMeterRegistry 같은 필수적인 bean이 제대로 로드되고 있는지 확인이 필요합니다. Spring Boot가 프로젝트에 정의되지 않은 빈을 필요로 할 수도 있기 때문에, 관련 라이브러리나 의존성을 추가해 보세요.
  4. 의존성 버전 충돌 확인:

    • 커스텀 라이브러리나 특정 기능을 추가하면서 발생할 수 있는 버전 충돌이 없는지 확인해 보세요. Maven 또는 Gradle을 사용하고 계신 경우, mvn dependency:tree 또는 ./gradlew dependencies 명령어를 사용해 의존성 트리를 확인할 수 있습니다.

유사한 질문과 답변으로는 다음을 참고하실 수 있습니다:

위의 링크들을 통해 본인의 상황과 유사한 문제 점검 및 해결 방법을 확인하실 수 있습니다.

저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다.
현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏
추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.

33강 도커 빌드 강의의 docker file

0

30

1

개발환경에서 도커 설정

1

92

2

vscode 터미널 설정 관련 질문

0

92

1

쿠버네티스 강의 언제 나오나요..

2

125

2

postgresql-repmgr:15 지원 종료에 따른 대체 이미지 변경 질문드립니다!

1

172

2

섹션 9. 레이어 관리에서 alpine OS 사용 관련 질문 있습니다!

1

68

2

도커 가상 네트워크와 Stateless 특징 관련 질문

1

73

2

우분투 설치

0

67

2

도커 보안을 실무에서 어떻게 대비하시는지 궁금합니다.

1

227

2

컨테이너를 활용한 개발환경 통일에 관하여

1

91

2

k8s 강의 일정

1

113

2

컨테이너의 Stateless 제약 관련 질문

0

95

1

docker push 하는 중 "single-platform image ..." 메세지가 나오고, docker hub에 image와 tag가 정상적으로 등록되지 않습니다.

2

97

1

docker pull [이미지] 다운로드시 에러 해결 방법 문의

1

431

2

강의 재생 오류

1

86

1

Remote JVM Debug Setting

1

105

1

빌드 방식에 대해 질문 있습니다.

1

99

2

컨테이너 레이어 질문 있습니다.

1

105

1

컨테이너 가상화 호스트 OS

1

154

2

강의 이미지 사용

1

167

2

도커컴포즈 오류

0

157

2

USER 명령어와 관련하여 질문드립니다

1

111

1

강의 예정

1

173

2

실행오류

1

209

3