Final Docker commands

Here are listed all the final commands needed to setup the multi containers application.

Running the MongoDB database

docker run --name mongodb \
           --rm \
           -d \
           -e MONGO_INITDB_ROOT_USERNAME=amandine \
           -e MONGO_INITDB_ROOT_PASSWORD=secret123 \
           -v mongo-volume:/data/db \
           --network goals-net \
           mongo

Building the backend image

Final backend Dockerfile
FROM node 
WORKDIR /app
COPY package.json /app 
RUN npm install
COPY . /app
EXPOSE 80
ENV MONGODB_USERNAME=root
ENV MONGODB_PASSWORD=secret
CMD ["npm", "start"]
docker build . -t backend-images

Running the backend image

docker run --name goals-backend \
            -v D:\Offensive_Notes\Udemy\Docker_Kubernetes_PraticalGuide_2022\multi-01-starting-setup\backend:/app \
            -v /app/node_modules 
            -v logs:/app/logs 
            -p 80:80
            --rm 
            --network goals-net 
            -e MONGODB_USERNAME=amandine 
            -e MONGODB_PASSWORD=secret123
            backend-images

Building the frontend image

Final frontend Dockerfile
FROM node
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
EXPOSE 3000
CMD ["npm", "start"]
docker build . -t frontend-images

Running the frontend image

docker run --name goals-frontend \ 
           -d \
           --rm \ 
           -it \
           -p 3333:3000 \
           -v D:\Offensive_Notes\Udemy\Docker_Kubernetes_PraticalGuide_2022\multi-01-starting-setup\frontend\src:/app/src \   
           frontend-images

Last updated