Skip to content

Instantly share code, notes, and snippets.

@Dizolivemint
Last active November 17, 2021 23:52
Show Gist options
  • Save Dizolivemint/7c5e29ab6e338c55ddb75db19934d6a1 to your computer and use it in GitHub Desktop.
Save Dizolivemint/7c5e29ab6e338c55ddb75db19934d6a1 to your computer and use it in GitHub Desktop.

Revisions

  1. Dizolivemint revised this gist Nov 17, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # Docker
    ```docker build .``` will run the Dockerfile to create an image
    ```docker build . -t [Dockerhub-username]/[image-name]:[v1]``` build an image with a specific version
    ```docker push [Dockerhub-username]/[image-name][v1]``` push to dockerhub
    ```docker build . -t [Dockerhub-username]/[image-name]:[v1]``` build an image with a specific version
    ```docker push [Dockerhub-username]/[image-name][v1]``` push to dockerhub
    ```docker images``` will print all the available images
    ```docker run {IMAGE_ID}``` will run a container with the image
    ```docker run -d {IMAGE_ID}``` will run a container with the image in the background
  2. Dizolivemint revised this gist Nov 17, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    # Docker
    ```docker build .``` will run the Dockerfile to create an image
    ```docker build . -t [Dockerhub-username]/[image-name]:[v1]``` build an image with a specific version
    ```docker push [Dockerhub-username]/[image-name][v1]``` push to dockerhub
    ```docker images``` will print all the available images
    ```docker run {IMAGE_ID}``` will run a container with the image
    ```docker run -d {IMAGE_ID}``` will run a container with the image in the background
  3. Dizolivemint revised this gist Nov 17, 2021. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -57,11 +57,15 @@ Delete any services that have an associated EXTERNAL-IP value. These services ar
    ```kubectl delete svc <service-name>```
    Delete the cluster and its associated nodes with the following command, replacing <prod> with your cluster name.
    ```eksctl delete cluster --name <prod>```
    Inspect a pod
    ```kubectl logs <podname>```

    Apply env variables and secrets
    ```kubectl apply -f aws-secret.yaml```
    ```kubectl apply -f env-secret.yaml```
    ```kubectl apply -f env-configmap.yaml```
    Remove env variables and secrets
    ```kubectl delete -f <config.yaml>```
    Deployments - Double check the Dockerhub image name and version in the deployment files
    ```kubectl apply -f deployment.yaml```
    Service
  4. Dizolivemint revised this gist Nov 15, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,7 @@ Run the docker image
    Check env variables
    ```docker-compose config```
    Stop docker compose
    ```docker-compose down```
    ```docker-compose down --remove-orphans```
    To delete all dangling images
    ```docker image prune --all```

  5. Dizolivemint revised this gist Nov 15, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    # Docker
    ```docker build .``` will run the Dockerfile to create an image
    ```docker images``` will print all the available images
    ```docker run {IMAGE_ID}``` will run a container with the image
  6. Dizolivemint revised this gist Nov 15, 2021. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -64,4 +64,15 @@ Apply env variables and secrets
    Deployments - Double check the Dockerhub image name and version in the deployment files
    ```kubectl apply -f deployment.yaml```
    Service
    ```kubectl apply -f service.yaml```
    ```kubectl apply -f service.yaml```

    # Expose IP
    Check the deployment names and their pod status
    ```kubectl get deployments```
    Create a Service object that exposes the frontend deployment
    The command below will ceates an external load balancer and assigns a fixed, external IP to the Service.
    ```kubectl expose deployment frontend --type=LoadBalancer --name=publicfrontend```
    Check name, ClusterIP, and External IP of all deployments
    ```kubectl get services```
    ```kubectl get pods``` It should show the STATUS as Running
    For more info, refer to [this tutorial](https://kubernetes.io/docs/tutorials/stateless-application/expose-external-ip-address/)
  7. Dizolivemint revised this gist Nov 15, 2021. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -55,4 +55,13 @@ List all services running in your cluster.
    Delete any services that have an associated EXTERNAL-IP value. These services are fronted by an Elastic Load Balancing load balancer, and you must delete them in Kubernetes to allow the load balancer and associated resources to be properly released.
    ```kubectl delete svc <service-name>```
    Delete the cluster and its associated nodes with the following command, replacing <prod> with your cluster name.
    ```eksctl delete cluster --name <prod>```
    ```eksctl delete cluster --name <prod>```

    Apply env variables and secrets
    ```kubectl apply -f aws-secret.yaml```
    ```kubectl apply -f env-secret.yaml```
    ```kubectl apply -f env-configmap.yaml```
    Deployments - Double check the Dockerhub image name and version in the deployment files
    ```kubectl apply -f deployment.yaml```
    Service
    ```kubectl apply -f service.yaml```
  8. Dizolivemint revised this gist Nov 15, 2021. 1 changed file with 38 additions and 1 deletion.
    39 changes: 38 additions & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,11 @@
    ```docker ps``` will print all the running containers
    ```docker kill {CONTAINER_ID}``` will terminate the container

    Open bash into a particular container
    ```docker exec -it <container-id> bash```
    Navigate to the specific file to ensure that your edits are there.
    ```cat <qualified-filename>```

    Viewing Logs
    ```docker logs```

    @@ -18,4 +23,36 @@ Include dead containers
    ```docker ps -a```

    View Details of Docker Objects
    ```docker inspect```
    ```docker inspect```

    # Docker Compose
    Make sure the Docker services are running in your local machine
    Remove unused and dangling images
    ```docker image prune --all```
    Run this command from the directory where you have the "docker-compose-build.yaml" file present
    ```docker-compose -f docker-compose-build.yaml build --parallel```
    Run the docker image
    ```docker-compose up```
    Check env variables
    ```docker-compose config```
    Stop docker compose
    ```docker-compose down```
    To delete all dangling images
    ```docker image prune --all```


    EKSCTL to auto provision a cluster
    ```eksctl create cluster --name myCluster --region=us-west-1 --nodes-min=2 --nodes-max=3```

    Once you get the success confirmation, run
    ```kubectl get nodes```

    Describe stacks
    ```eksctl utils describe-stacks --region=us-west-1 --cluster=myCluster```

    List all services running in your cluster.
    ```kubectl get svc --all-namespaces```
    Delete any services that have an associated EXTERNAL-IP value. These services are fronted by an Elastic Load Balancing load balancer, and you must delete them in Kubernetes to allow the load balancer and associated resources to be properly released.
    ```kubectl delete svc <service-name>```
    Delete the cluster and its associated nodes with the following command, replacing <prod> with your cluster name.
    ```eksctl delete cluster --name <prod>```
  9. Dizolivemint revised this gist Oct 8, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    ```docker build .``` will run the Dockerfile to create an image
    ```docker images``` will print all the available images
    ```docker run {IMAGE_ID}``` will run a container with the image
    ```docker run -d {IMAGE_ID}``` will run a container with the image in the background
    ```docker ps``` will print all the running containers
    ```docker kill {CONTAINER_ID}``` will terminate the container

  10. Dizolivemint revised this gist Oct 8, 2021. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,20 @@
    docker build . will run the Dockerfile to create an image
    docker images will print all the available images
    docker run {IMAGE_ID} will run a container with the image
    docker ps will print all the running containers
    docker kill {CONTAINER_ID} will terminate the container
    ```docker build .``` will run the Dockerfile to create an image
    ```docker images``` will print all the available images
    ```docker run {IMAGE_ID}``` will run a container with the image
    ```docker ps``` will print all the running containers
    ```docker kill {CONTAINER_ID}``` will terminate the container

    Viewing Logs
    docker logs
    ```docker logs```

    Attaching to a Container
    docker exec -it sh
    ```docker exec -it sh```

    View Docker Processes
    docker ps
    ```docker ps```

    Include dead containers
    docker ps -a
    ```docker ps -a```

    View Details of Docker Objects
    docker inspect
    ```docker inspect```
  11. Dizolivemint revised this gist Oct 8, 2021. 1 changed file with 11 additions and 6 deletions.
    17 changes: 11 additions & 6 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -2,14 +2,19 @@ docker build . will run the Dockerfile to create an image
    docker images will print all the available images
    docker run {IMAGE_ID} will run a container with the image
    docker ps will print all the running containers
    docker kill {CONTAINER_ID} will terminate the container
    docker kill {CONTAINER_ID} will terminate the container

    Viewing Logs
    docker logs
    docker logs

    Attaching to a Container
    docker exec -it sh
    docker exec -it sh

    View Docker Processes
    docker ps
    docker ps

    Include dead containers
    docker ps -a
    docker ps -a

    View Details of Docker Objects
    docker inspect
    docker inspect
  12. Dizolivemint revised this gist Oct 8, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,6 @@ docker exec -it sh
    View Docker Processes
    docker ps
    Include dead containers
    docker ps -a
    docker ps -a
    View Details of Docker Objects
    docker inspect
  13. Dizolivemint revised this gist Oct 8, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -9,5 +9,7 @@ Attaching to a Container
    docker exec -it sh
    View Docker Processes
    docker ps
    Include dead containers
    docker ps -a
    View Details of Docker Objects
    docker inspect
  14. Dizolivemint revised this gist Oct 8, 2021. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion docker.md
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,12 @@ docker build . will run the Dockerfile to create an image
    docker images will print all the available images
    docker run {IMAGE_ID} will run a container with the image
    docker ps will print all the running containers
    docker kill {CONTAINER_ID} will terminate the container
    docker kill {CONTAINER_ID} will terminate the container
    Viewing Logs
    docker logs
    Attaching to a Container
    docker exec -it sh
    View Docker Processes
    docker ps
    View Details of Docker Objects
    docker inspect
  15. Dizolivemint created this gist Oct 8, 2021.
    5 changes: 5 additions & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    docker build . will run the Dockerfile to create an image
    docker images will print all the available images
    docker run {IMAGE_ID} will run a container with the image
    docker ps will print all the running containers
    docker kill {CONTAINER_ID} will terminate the container