inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

따라하며 배우는 도커와 CI환경 [2023.11 업데이트]

Docker Compose 파일 작성하기

레디스 버전에 따른 오류

1134

윤혜원

작성한 질문수 3

0

 
"dependencies": {
"express": "4.17.2",
"redis": "4.0.1"
}
 
레디스가 4.0.1 일때 아래와 같은 오류가 발생했습니다.
혹시나 버전을 강의와 같은 3.0.1로 수정하니 정상 동작합니다. 이게 무슨 문제인건가요?
 
node-app_1 | (node:1) UnhandledPromiseRejectionWarning: Error: The client is closed
node-app_1 | at Commander._RedisClient_sendCommand (/usr/src/app/node_modules/@node-redis/client/dist/lib/client/index.js:393:31)
node-app_1 | at Commander.commandsExecutor (/usr/src/app/node_modules/@node-redis/client/dist/lib/client/index.js:160:154)
node-app_1 | at Commander.BaseClass.(anonymous function) [as set] (/usr/src/app/node_modules/@node-redis/client/dist/lib/commander.js:8:29)
node-app_1 | at Object.<anonymous> (/usr/src/app/index.js:15:8)
node-app_1 | at Module._compile (internal/modules/cjs/loader.js:778:30)
node-app_1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
node-app_1 | at Module.load (internal/modules/cjs/loader.js:653:32)
node-app_1 | at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
node-app_1 | at Function.Module._load (internal/modules/cjs/loader.js:585:3)
node-app_1 | at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
node-app_1 | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
node-app_1 | (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
 

docker aws github 데이터 엔지니어링 travis-ci cicd

답변 3

1

김윤영

안녕하세요 소스코드 compose 가 안돼서 못넘어가고있습니다.... 소스코드는 올려주신거 그대로 작성하였는데 똑같습니다 ㅠ 아무리 구글링을해도 나오지않습니다... 도와주세요ㅠ

 

0

unchaptered

지금이면 해결하셨을 것 같은데,
혹시 아직 해결하지 못하셨을 까봐 답변을 남깁니다.
아래 방법으로 해결이 되지 않거나 혹은 다른 에러 가 발생할 수 있습니다.
해당 하는 경우에는 키워드 찾으셔서 구글링 하시면 99 % 로 게시글이 나올 것이며, 나오지 않는 경우는 stackoverflow 에 OS, 사용하는 버전, git 링크 등을 첨부하셔서 질문 하시면 답변 돌아올 것 같습니다.

 

발견한 문제

Cannot start service node-app: Ports ar not availbale : listen tcp ~ 이 뒤는 잘려있네요...

몇 번 포트를 사용하셨는지 모르겠지만 강의처럼 8080 포트를 사용하셨다면 에러가 뜰 가능성이 있는데요.
그 이유는 MySQL 혹은 PostgreSQL 이 8080 포트를 쓰는 것으로 알고 있습니다.
혹은 5000 포트 또한 자주 사용되는 것으로 알고 있습니다.

강의 도중에 나왔던 설명안 대로 포트 매핑 을 49160:8000 으로 진행하면 해결 되실 수도 있을 것 같네요.
안된다면 다른 포트 4000, 3000 찾아서 사용하시면 될 것 같고 로컬(내 컴퓨터) 포트 사용 현황 은 사용 중인 TCP 포트 보기 로 구글링 하면 나올 듯 합니다.

 

발견한 문제

Cannot find module /usr/src/app/server.js

말 그대로 해당 파일이 없을 때, 뜨는 문제입니다.
에러가 발생하면 말 그대로 해당 지점을 확인 해봐야 하는데, 저도 docker 는 낯설어서 에러가 뜬 상태로 실행을 유지 에러가 뜨며 실행 중단 인지 구분이 되지 않습니다.

 

docker ps 로 컨테이너 리스트 확인하고 실행 중이라면 아이디 확인해서
docker exec -it 컨테이너 아이디  sh 으로 쉘 열어 주신 다음에 
ls 입력해주세요.

 

예상 가능한 경우의 수는 2 가지 일 것 같은데,

1. home 을 비롯한 수많은 디랙토리가 출력되는 경우
2. package.json 과 같은 개발자가 작성한 파일만 출력되는 경우

 

1번의 경우는 dockerfile, docker-compose 에 오타가 있는 것이 아닐까 생각합니다.
저도 똑같이 작성하였으니 레포 남겨두겠습니다.
unchaptered/22-05-docker-express: docker test project, from 2022-05-01 (github.com)


2번의 경우처럼, 제대로 작성하였는데도 에러가 뜨는 경우는 잘 모르겠습니다.
그런 경우에는 따로 OS, Docker 버전, Github Repo 첨부하셔서  질문 별도로 작성하시면 강사님께서 도와주시시 않을까... 생각해봅니다.

0

John Ahn

const express = require("express");
const redis = require("redis");

//레디스 클라이언트 생성
const client = redis.createClient({
socket: {
host: "redis-server",
port: 6379
}
});

const app = express();

app.get('/', async (req, res) => {
await client.connect();
let number = await client.get('number');
if (number === null) {
number = 0;
}
console.log('Number: ' + number);
res.send("숫자가 1씩 올라갑니다. 숫자: " + number)
await client.set("number", parseInt(number) + 1)
await client.disconnect();;;
})


app.listen(8080);
console.log('Server is running');

0

John Ahn

안녕하세요 !! 
아 버전이 바뀌었네요 !! 
알려주셔서 감사합니다.

알려주셔서 어떻게 소스 코드를 바꿔야하는지 찾아봤는데 
정보가 아직 많이 부족한거 같네요 ... 그래서 깃허브 이슈에 사람들이 많이 질문하고 있어서
저도 아래에 보시면 질문을 올려놨어요 !! 

https://github.com/redis/node-redis/issues/1790


현재 제가 질문해놓은건 버전 4에서 createClient 부분에 host  프로퍼티를 없애 버려서 
어떤식으로 레디스 서버에 접근할수있는지 모르겠네요 ...

export interface RedisClientOptions<M extends RedisModules, S extends RedisScripts> extends RedisPlugins<M, S> {
url?: string;
socket?: RedisSocketOptions;
username?: string;
password?: string;
name?: string;
database?: number;
commandsQueueMaxLength?: number;
readonly?: boolean;
legacyMode?: boolean;
isolationPoolOptions?: PoolOptions;
}

답변 받고 소스 코드 변경하면  업데이트 해놓겠습니다 
그동안 버전 3으로 이용해주시면 감사하겠습니다 !!!  



Docker Containers간 통신 할 때 나타나는 에러 강의 질문

0

84

1

WINDOW + Vite를 사용하여 소스 코드 변경이 반영되지 않는 현상

0

86

1

도커 컨테이너 끼리 SSL 통신 시 문제가 생깁니다..

0

221

1

도표 강의 자료 사용이 불가합니다. (권한 문제)

0

141

1

Docker compose 관련 공유

0

145

1

트레비스가 유료화가 되어 테스트가 어려워 챕터8에서 고민중입니다.

0

81

1

강사님 혹시 vscode 어떤 테마 쓰시나요..?

0

289

1

The instance profile aws-elasticbeanstalk-ec2-role associated with the environment does not exist.

0

109

1

travis ci가 이제 유료화가 된 것 같습니다;;;

0

212

2

docker-compose up 에러 공유 드립니다

0

294

1

Elastic Beanstalk에서 도메인 클릭시 react 이미지가 안나오고 다른 화면이 나오는데

0

175

1

도커 빌드 시간이 너무 오래걸려요..

0

1072

2

docker-compose down 이후에도 containers에 redis가 남아 있는 이유

0

168

1

도커 볼륨이 작동이 안되는것 같아서 질문드립니다!

0

215

2

docker-compose 가 Docker Desktop 에서 빠진건가요? command not found 라고 뜨네요

0

282

1

Error response from daemon: The system cannot find the file specified.

0

221

1

draw.io 오류

0

658

1

Docker Volume 오류(reference, lowercase)

0

566

1

[섹션3 - 내가 만든 이미지 기억하기 쉬운 이름 주기] 네이밍/태그 에러

0

227

1

axios오류 문의드립니다!

0

337

1

node.js version

0

488

1

안녕하세요 마지막 강의 질문 있습니다.

0

436

1

Deploy를 계속 실패합니다.

3

1387

4

TravisCI에서 계속 에러가 납니다....

0

362

1