Skip to content

Instantly share code, notes, and snippets.

@deepanshumehtaa
Created August 28, 2023 15:46
Show Gist options
  • Save deepanshumehtaa/ee0a1129a21bf8f3c94c51a856709040 to your computer and use it in GitHub Desktop.
Save deepanshumehtaa/ee0a1129a21bf8f3c94c51a856709040 to your computer and use it in GitHub Desktop.
docker compose and Docker File : Django on container and SQL locally
# Docker Compose, a tool for defining and running multi-container Docker applications.
# Commands to Run
# docker-compose -f ./docker-compose.dev.yaml build
# docker-compose -f ./docker-compose.dev.yaml up -d
# docker-compose exec web python manage.py migrate --noinput
version: "3.9"
services:
web:
container_name: web-dev
network_mode: bridge
command: python3 manage.py runserver 0.0.0.0:8000 # don't add word `localhost`
restart: unless-stopped
build:
context: ..
# name of dockerfile to build that service
dockerfile: ../Dockerfile
volumes:
- .:/code
ports:
# OUT:IN
- "8000:8000"
networks:
- my_network
depends_on:
# - cache
extra_hosts:
- "docker.for.mac.localhost:host-gateway"
# docker network ls
# docker network inspect bridge
networks:
my_network:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment