DEV Community

Nithu Varshini
Nithu Varshini

Posted on

Docker

Docker Desktop

1.Open terminal

2.Run

docker pull nginx
docker pull httpd
docker pull docker/getting-started
Enter fullscreen mode Exit fullscreen mode

in docker hub terminal to pull docker images

3.To create a container run

docker run -idt nginx
Enter fullscreen mode Exit fullscreen mode

it will give the container ID

4.Port Mapping ( -p <HOST-PORT>:<CONTAINER_PORT> ) for creating container after creating image
run docker run -idt -p 80:80 nginx

docker run -idt -p 81:80 httpd

docker run -idt -p 82:80 docker/getting-started

React Application

1.Create Dockerfile

2.Create image run docker build -t knithuvarshini/portfolio . in terminal

3.Then run docker run -idt -p 83:80 knithuvarshini/portfolio:latest

4.Push the image to docker
docker login
docker push knithuvarshini/portfolio:latest

EC2 Instance

sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Enter fullscreen mode Exit fullscreen mode
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
Enter fullscreen mode Exit fullscreen mode
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

sudo systemctl status docker

sudo groupadd docker

sudo usermod -aG docker $USER

newgrp docker

docker run hello-world
Enter fullscreen mode Exit fullscreen mode

Minikube

curl -LO https://github.com/kubernetes/minikube/releases/latest/download/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64
Enter fullscreen mode Exit fullscreen mode

minikube start

snap install kubectl --classic
kubectl version --client

kubectl get po -A

Enter fullscreen mode Exit fullscreen mode


kubectl get pods -A

nano pod.yaml
kubectl apply -f pod.yaml
kubectl get pods
Enter fullscreen mode Exit fullscreen mode

Do the same for httpd and getting-started-pod

Create .yaml file:
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: NodePort
selector:
app: nginx
ports:
- port: 80
targetPort: 80
nodePort: 30080

Top comments (0)