Reputation: 339
I am new in docker. I want to run my django app on port 9000. After command docker-compose up I am getting this message
Creating motion_full_version_backend_1 ... done
Attaching to motion_full_version_backend_1
backend_1 | Unknown command: 'makemigrations\r'. Did you mean makemigrations?
backend_1 | Type 'manage.py help' for usage.
backend_1 | Unknown command: 'migrate\r'. Did you mean migrate?
backend_1 | Type 'manage.py help' for usage.
" is not a valid port number or address:port pair.*
My Dockerfile :
FROM continuumio/miniconda3:latest
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
RUN apt-get update && apt-get upgrade -y && apt-get install -qqy \
wget \
bzip2 \
graphviz
RUN mkdir -p /backend
COPY ./backend/requirements.yml /backend/requirements.yml
# Create environment
RUN /opt/conda/bin/conda env create -f /backend/requirements.yml
# Add env path to environment
ENV PATH /opt/conda/envs/backend/bin:$PATH
# Activate interpreter
RUN echo "source activate backend" >~/.bashrc
# Create a scripts folder
RUN mkdir -p /scripts
COPY ./scripts /scripts
RUN chmod +x ./scripts*
COPY ./backend /backend
WORKDIR /backend
I am using script to run it
python manage.py makemigrations
python manage.py migrate
python manage.py runserver 0.0.0.0:9000
my docker-compose.yml looks like this
version: '3'
services:
backend:
image: backend:latest
restart: always
env_file:
- ./envs/dev.env
command: 'sh /scripts/dev.sh'
ports:
- "9000:9000"
Any Ideas what I am doing wrong?
Upvotes: 1
Views: 1983
Reputation: 263469
Your script has windows linefeeds within it, e.g. the \r
you see in the output:
makemigrations\r
Since docker is running this command within a Linux environment, you need to adjust your script linefeeds for the Linux \n
(without any \r
). Linux sees those carriage returns as part of the string in the command you are running or port number you are passing. Adjust the linefeeds in your editor or using a tool like dos2unix.
Upvotes: 3