[Answered ]-Using network_mode='host' in docker-compose break run: host type networking can't be used with links

2👍

This is because docker-compose run runs another container, a new container, that it is trying to attach to the same network as your docker-compose up container, so that they can work together.

This won’t work with host networking, due to the publishing rules.

Instead, you could use docker-compose exec web python manage.py periodico

0👍

I know this answer is late for the question, but docker still has the same problem. The problem with @RawKode for me was undefined variables such as DATABASE_URL. You can solve it with

docker run -it --rm --net=host <image_name> <command>
adding -e / --env-file and variables names.

The command is longer but it works exactly the same as docker-compose run.

Leave a comment