简体   繁体   中英

Make django work with `network_mode: host` in docker-compose

Related project: https://github.com/mjozan/docker-compose-django-react

Hello

This project is a simple app using react and django with docker-compose.

As I want to make this project work with vscode Codespace (cf this issue ), I put network_mode: host on the django service in the docker-compose file.

However, by doing so, django is not running anymore (the container seems to run but the browser cannot access localhost:8000).

I would like to know how I could solve this so that all services work. Thank you for your answer.

Few things could be:

First check you do not have a service running on port 8000. Asumming you use Linux.

netstat -tnlp

If port is free try: network_mode: "host"

Which I use often.

If even this doesnt solve the issue, you may have to edit your /etc/hosts file.

Adding something like to /etc/hosts

0.0.0.0 django

Now try django:8000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM