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 이렇게 포트가 뜸
포트가 안뜨면 포트 바인딩을 해주면 됨