- Combining Multiple Services to One App
- Working with Multiple Containers
Run the following commands to start the necessary containers for building the target application.
-
Network
docker network create goals-net
-
MongoDB Database
# Run Container docker run \ --network goals-net \ -v data:/data/db \ -e MONGO_INITDB_ROOT_USERNAME=user \ -e MONGO_INITDB_ROOT_PASSWORD=secret \ --rm -d --name mongodb \ mongo
-
NodeJS Backend
# Build Image docker build -t goals-node . # Run Container docker run \ --network goals-net \ -v logs:/app/logs \ -v $(pwd):/app \ -v /app/node_modules \ -e MONGODB_USERNAME=user \ -p 80:80 \ --rm -d --name goals-backend \ goals-node
-
ReactJS Frontend
# Build Image docker build -t goals-react . # Run Container docker run \ -v $(pwd)/src:/app/src \ -p 3000:3000 \ --rm -d --name goals-frontend \ goals-react
- Three, long docker run commands
It would be great to not have to remember or save those and to avoid running them individually. - Development-only setup
Not optimized for production, shouldn’t be executed like this on a production server