docker network create mongo-network
docker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=password --name mongodb --net mongo-network mongo
docker run -d -p 8081:8081 -e ME_CONFIG_MONGODB_ADMINUSERNAME=admin -e ME_CONFIG_MONGODB_ADMINPASSWORD=password --net mongo-network --name mongo-express -e ME_CONFIG_MONGODB_SERVER=mongodb mongo-express
NOTE: Creating docker-network in optional. You can start both containers in a default network. In this case, just emit --net
flag in docker run
command
http://localhost:8081
cd app
npm install
node server.js
http://localhost:3000
docker-compose -f docker-compose.yaml up
http://localhost:8080
cd app
npm install
node server.js
http://localhost:3000
docker build -t hoangviet2001/demo-app:latest .
docker push hoangviet2001/demo-app:latest
The dot "." at the end of the command denotes location of the Dockerfile.
minikube start
minikube status
kubectl apply -f mongo-config.yaml
kubectl apply -f mongo-secret.yaml
kubectl apply -f mongo.yaml
kubectl apply -f webapp.yaml
-
Check basic information of each component in K8s
kubectl get node kubectl get pod kubectl get svc kubectl get all
-
Check extended information of each component in K8s
kubectl get pod -o wide kubectl get node -o wide
-
Check details of a specific component in K8s
kubectl describe svc {svc-name} kubectl describe pod {pod-name}
-
Check the logs for a container in a pod.
kubectl logs {pod-name}
minikube stop
minikube delete --all
⚠️ Known issue - Minikube IP not accessible
If you can't access the NodePort service webapp with MinikubeIP:NodePort
, execute the following command:
minikube service webapp-service
- webapp image on Docker Hub: https://hub.docker.com/layers/hoangviet2001/demo-app/latest/images/sha256-3b00b5fa786dc9f9846488c58c9100ad25e1f8eaa13b401e95a23cd4df3960c7?tab=layers
- mongo image on Docker Hub: https://hub.docker.com/_/mongo