1👍
The Compose command:
overrides the Dockerfile CMD
. docker run
doesn’t look at the docker-compose.yml
file at all, and docker run
with no particular command runs the image’s CMD
. You haven’t declared anything for that, which is why the container exits immediately.
Leave the entrypoint script unchanged (or even delete it entirely, since it doesn’t really do anything). Add a CMD
line to the Dockerfile
CMD python manage.py migrate && python manage.py runserver 0.0.0.0:8000
Now plain docker run
as you’ve shown it will attempt to start the Django server. For the Celery container, you can still pass a command override
docker run -d --net ... your-image \
celery -A testapp worker -l INFO -c 4
If you do deploy to Kubernetes, and you keep the entrypoint script, then you need to use args:
in your pod spec to provide the alternate command, not command:
.
0👍
I think that is because the commands to run the django server are in the docker-compose.yml
.
You should move these commands inside the entrypoint.
set -o errexit
set -o pipefail
set -o nounset
python manage.py migrate && python manage.py runserver 0.0.0.0:8000
exec "$@"
Pay attention that this command python manage.py runserver 0.0.0.0:8000
will start the application with a development server that cannot be used for production purposes.
You should look for gunicorn or similar.
- [Answered ]-Authorization header in AngularJS not working
- [Answered ]-Ajax powered form submission working only once Django
- [Answered ]-How to intercept and add to header auth_token for each request?
- [Answered ]-Django From Choices Tuple Concatnation
- [Answered ]-Can't access Django admin page it gives an error