Create a network for communication between backend and mongo container
docker network create webAppNet
docker run mongo
docker run --name mongodb --rm -d --network webAppNet -v mongodata:/data/db -e MONGO_INITDB_ROOT_USERNAME=corgi -e MONGO_INITDB_ROOT_PASSWORD=secret mongo
docker build --tag backend-img .
docker run --name nodeApp --rm -d -p 80:80 --network webAppNet -v logs:/app/logs -v /Users/lamtan/Documents/dev/git/docker-practice-multicontainer/backend:/app -v /app/node_modules -e MONGODB_USERNAME=corgi backend-img
docker build --tag frontend-img .
docker run --name reactApp --rm -it -p 3000:3000 -v /Users/lamtan/Documents/dev/git/docker-practice-multicontainer/frontend/src:/app/src frontend-img
Absolute path of all bind volumes above must be modified depending on the machine
Ex:
/Users/lamtan/Documents/dev/git/docker-practice-multicontainer/backend
/Users/lamtan/Documents/dev/git/docker-practice-multicontainer/frontend/src
The version using docker-compose is on the branch with-docker-compose