Created
October 31, 2018 15:41
-
-
Save glyons/281d3c3d1ed98b9aceaa82051fedd0fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Microsft Training - Developing Applications with Containers | |
============================================================ | |
aka.ms/wscontainers | |
docker run | |
Get an Image | |
=================== | |
from Dockerhub | |
docker pull tutum/wordpress | |
docker run -d -p 90:80 tutum/wordpress | |
-d detach mode (let it run)] | |
docker search tutum | |
docker search tutum/wordpress | |
docker search microsoft/aspnet --limit 5 (best match) | |
--no-trunc (full description) | |
Remove Image | |
================ | |
docker -rmi imagename | |
Tip: How to stop and remove with part of the Container ID | |
=========================================================== | |
docker stop aa | |
docker rm aa | |
-f force | |
How to pipe into the remove | |
============================ | |
docker rm -f $(docker ps -aq) | |
See the layers of a Docker Container | |
======================================== | |
docker inspect | |
docker inspect 11 | findstr "IPAddress" or docker inspect 11 | grep "IPAddress" | |
Dockerfile | |
================ | |
LABEL | |
RUN | |
WORKDIR | |
ADD - get stuff from url | |
COPY | |
CMD - | |
ENTRYPOINT - Keeps the containers running/alive such as Service WatchDog use /dev/null | |
EXPOSE - ports | |
Docker Tags | |
================== | |
company/project - should use | |
use tags for different version/history etc.. | |
default is always latest | |
-t mccontainer:v1 | |
Docker Build | |
================= | |
docker build -tmycontainer:v1 . (dot is the context) | |
Publishing dotNEt | |
==================== | |
dotnet | |
dotnet restore | |
TIP: add nuget.cfg to your project for http Proxy | |
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<config> | |
<add key="dependencyVersion" value="Highest" /> | |
<add key="https_proxy" value="https://proxy:80800" /> | |
</config> | |
</configuration> | |
dotnet build | |
dotnet publish -o published (this will do the restore and build altogether) | |
Dockerfile for dotNEt | |
===================== | |
FROM microsoft/aspnetcore:2.0 | |
WORKDIR /app | |
COPY published ./ | |
ENTRYPOINT ["dotnet", "mywebapp.dll"] | |
Windows Containers (Node.js) | |
==================== | |
2GB - Nano <1 seconds | |
11GB - ServerCore <2 seconds | |
Hyper-V Containers (it has own Kernel) Nano 5s and Server core 10s | |
Microsoft SQL on Windows/Linux Docker= | |
----------------------------------------- | |
Connecting to a SQL Server container use the ContainerID:portnumber such as 1433 | |
Logging into Private Registries | |
====================================== | |
docker login URIRegistry -u <username> -p <password> | |
docker pull URIRegistry/dockerimage | |
eg docker pull dockerreg.i386.com/webappp | |
Find out CPU/Memory usage | |
=============================== | |
docker stats | |
docker top <container> (like unix) | |
docker events | |
Networking | |
=================== | |
docker inspect nat - to see all the containers in the networks | |
docker network create -d transpatent tlan - to make a transpatent network | |
Now specific a network for a container docker run | |
K8S | |
==== | |
Install kubectl tool which allows you to run commands against Kubernetes cluster. Skip this step if it is already installed on your machine (run “kubectl” to see if the command is recognized). | |
Windows: | |
choco install -y kubernetes-cli | |
Linux: | |
sudo apt-get -y update && sudo apt-get -y upgrade | |
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl | |
chmod +x ./kubectl | |
sudo mv ./kubectl /usr/local/bin/kubectl | |
In Linux, due to current bug with azure-cli you need to revert to 2.0.23-1 version. | |
sudo apt-get -y purge azure-cli | |
sudo apt-get -y install azure-cli=2.0.23-1 | |
K8S | |
=== | |
https://kubernetes.io/docs/tutorials/stateless-application/expose-external-ip-address/ | |
kubectl run hello-world --replicas=5 --labels="run=load-balancer-example" --image=gcr.io/google-samples/node-hello:1.0 --port=8080 | |
Important to know and change to the relevant context. | |
kubectl config get-contexts - List Clusters available | |
kubectl config current-context - Displays the current context of Pods and Nodes | |
Create a deployment and name it “nginx” | |
kubectl run nginx --image=nginx --port=80 | |
kubectl delete deployment nginx | |
kubectl get deployment | |
kubectl expose deployment nginx --type=NodePort (Services ) | |
kubectl get services - Networking for your pod deployments | |
kubectl delete service nginx | |
kubectl expose deployment nginx --type=LoadBalancer (Services as LoadBalancer) | |
kubectl scale --replicas=3 deployment/nginx | |
kubectl get pods - list the pod and show the number of services eg. Nginx running/alive | |
kubectl get nodes - list nodes (i.e computers)# | |
kubectl get pods -o wide | |
kubectl proxy (allows to create a tunnel) | |
K8S Labels - use them to manage updates/removes etc... | |
Minikube | |
Fix dos files on unix apt-get / yum dos2unix | |
================= | |
Use to develop locally, cut down version of k8s. Single node on the computer | |
Minikube on Windows | |
======================== | |
Installing see - https://github.com/kubernetes/minikube | |
https://rominirani.com/tutorial-getting-started-with-kubernetes-on-your-windows-laptop-with-minikube-3269b54a226 | |
https://blog.alexellis.io/minikube-behind-proxy/ | |
Azure | |
===== | |
CLI - https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest | |
az login | |
Kubenetes under Docker for Windows | |
==================================== | |
Run under Powershell (Administrator) | |
[Environment]::SetEnvironmentVariable("KUBECONFIG", $HOME + ".kube\config", [EnvironmentVariableTarget]::Machine) | |
Install the Kubenetes Dashboard on port 8001 | |
================================================ | |
kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml | |
Local download the yaml file | |
kubectl create -f kubernetes-dashboard.yaml | |
Remember to run kubectl proxy | |
https://www.ntweekly.com/2018/05/25/deploy-kubernetes-web-ui-dashboard-docker-windows/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment