Dockerfile로 Django restFramework를 실행시켰는데 안될 때

나의 재물운? 연애운은?

AI가 봐주는 내 사주팔자 - 운세박사

https://aifortunedoctor.com/

Dockerfile로 Django restFramework를 실행시켰는데 안될 때

영리치 0 983 2023.02.09 15:42

Dockerfile

# Use an official Python image as the base image
FROM python:3.9

# Set the working directory in the container
WORKDIR /

# Copy the requirements.txt file to the container
COPY requirements.txt .

# Install the dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the code to the container
COPY . .

# Set the environment variable for Django
ENV PYTHONUNBUFFERED=1

# Expose port 8080 for Django
EXPOSE 8080

# Set the entrypoint for the container
# ENTRYPOINT [ "python", "manage.py", "runserver", "0.0.0.0:8080" ]
CMD python manage.py runserver 0.0.0.0:8080


위에 실행 시 실행이 안되는 이슈 존재함


docker build -t mapeditor1 .

docker run mapeditor1 

위에 명령어로 하면 안됨

이건 포트 바인딩이 안되어 있기 때문임


아래 명령어로 포트 바인딩을 해주면 됨

docker run -p 8080:8080 mapeditor1

즉, Docker에서 8080번 포트로 온 요청을 8080 포트로 바인딩 시켜준다는 것을 명시해줘야함


아래처럼 포트 바인딩을 해주면 8080:8080 or 80:80 이렇게 포트가 뜸

포트가 안뜨면 포트 바인딩을 해주면 됨

990564053_ktY3mHIL_e38bf8d76d9a7ed9b924ee8c9b01d080c0d833ab.png



Comments

나의 재물운? 연애운은?

AI가 봐주는 내 사주팔자 - 운세박사

https://aifortunedoctor.com/

Category
실시간 인기글
Magazine
훈남/훈녀
 
 
 
상점
Facebook Twitter GooglePlus KakaoStory NaverBand