- Docker
- Running a containerized Java application
- Network and ports
- List network types
- Create a new network
- inspect a network
- Run Apache Tomcat for the newly created network
- Run a busybox with the same network as myTomcat container
- Check if we can reach the tomcat webserver from the busybox
- Bind your host port to the container
- Map a random port to the exposed container port
- Find out the randomly allocated port
- Volumes
- Dockerfile
- Build the docker with the Dockerfile provided in this repository
- Run the newly built image (rest-example)
- Build the ping-example container from Dockerfile
- Run container in detached mode
- Attach to the detached container
- View logs of the running container
- Specify the log driver to write logs to
- Inspect a container
- Inspect containers using Go template engine
- Fetch the IP address from the metadata of the container
- Get stats of all (not only running) the containers
- Fetch container events
- Restart a container after it is shut down (in every case)
- Restart a container after it is shut down (with a non-zero exit status)
- Get the number of restarts of a container
- Discover the last time the container was started again
- Updating a restart policy on a running container
- Restrict the memory to 512 MB for the container
- Set memory reservation without setting the hard memory limit
- Set the Kernel memory limit
- Setting user memory and kernel memory for a container
- Set memory swappiness constraint for a container (0 to disable swaps, 100 all anonymous pages to swap out)
- Set the CPU usage limit for a container to 50\x of the CPU resource
- Constraint the container to get 50\x of the CPU usage every 50ms
- Set the number of CPU cores to be used by the container
- Updating constrains of a running container
- Java Microservices
- Kubernetes
docker run milkyway/java-hello-world
docker network ls
docker network create myNetwork
docker network inspect myNetwork
docker run -it --name myTomcat --net=myNetwork tomcat
docker run -it --net container:myTomcat busybox
wget localhost:8080
docker run -it --name myTomcat2 --net=myNetwork -p 8080:8080 tomcat
docker run -it --name myTomcat3 --net=myNetwork -P tomcat
docker port myTomcat3
OR check in:
docker inspect myTomcat3
Windows: docker run -v d:/docker_volumes/volume1:/volume -it busybox
Mac:docker run -v ~/volume1:/volume -it busybox
docker volume create --name myVolume
docker run -it -v myVolume:/volume --name myBusybox3 busybox
docker run -it -v myVolume:/volume --name myBusybox4 busybox
OR use -volumes-from
docker run -it -volumes-from myBusybox4 --name myBusybox5 busybox
docker volume rm myVolume
docker build . -t rest-example
docker run -p 8080:8080 -it rest-example
cd ping-example
docker build -t ping-example .
docker run ping-example
for sending ping to localhost
docker run ping-example www.google.com
to ping Google
docker run -d -p 8080:8080 rest-example
docker attach rest-example
docker logs -f rest-example
docker run log-driver=syslog rest-example
You can use journald
, splunk
, fluentd
, awslogs
, etc
docker inspect rest-example
docker inspect -f '{{.State.ExitCode}}' jboss.wildfly
docker inspect rest-example | jq -r '.[0].NetworkSettings.IPAddress'
docker stats -a
docker events
docker run --restart=always rest-example
docker run --restart=on-failure:5 rest-example
docker inspect -f "{{ .RestartCount }}" rest-example
docker inspect -f "{{ .State.StartedAt }}" rest-example
docker run -d -t rest-example
docker update --restart=always rest-example
docker run -it -m 512m ubuntu
docker run -it --memory-reservation 1G ubuntu /bin/bash
docker run -it --kernel-memory 100M ubuntu /bin/bash
docker run -it -m 1G --kernel-memory 100M ubuntu /bin/bash
Set memory swappiness constraint for a container (0 to disable swaps, 100 all anonymous pages to swap out)
docker run -it --memory-swappiness=0 ubuntu /bin/bash
docker run -it --cpu-quota=50000 ubuntu /bin/bash
docker run -it --cpu-quota=25000 --cpu-period=50000 ubuntu /bin/bash
docker run -it --cpuset 2 ubuntu
docker update --cpu-shares 512 -m 500M rest-example
cd dokuja
mvn clean package docker:build
mvn clean package docker:start
Or to stop the container
mvn docker:stop
mvn clean package docker:run
Mac: brew cask install minikube
Linux: curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \ && chmod +x minikube
sudo cp minikube /usr/local/bin && rm minikube
Windows: choco install minikube kubernetes-cli
minikube start
minikube dashboard
minikube addons list
minikube addons disable dashboard
minikube addons enable heapster
Mac: brew install kubernetes-cli
Linux: sudo snap install kubectl --classic
Windows: curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.14.0/bin/windows/amd64/kubectl.exe
kubectl get nodes
kubectl create -f service.yml
kubectl get services
kubectl get services --all-namespaces
kubectl describe service rest-example
kubectl create -f deployment.yml
kubectl get depployments
minikube service rest-example --url
curl $(minikube service dokuja --url)/books -H {"Content-Type: application/json"}
kubectl logs $(kubectl get pods | sed -n 2p | awk '{print $1;}')
kubectl exec -it $(kubectl get pods | sed -n 2p | awk '{print $1;}') -- /bin/bash
kubectl scale deployment dokuja --replicas=3
kubectl autoscale deployment dokuja --cpu-percent=50 --min=1 --max=5
kubectl get events
kubectl delete deployment dokuja
kubectl delete service dokuja
kubectl proxy --port=8080
In a separate bash session:
curl http://localhost:8080/api/
curl -s http://localhost:8080/api/v1/namespaces/default/services \
-XPOST -H 'Content-Type: application/json' -d@service.json
curl -s http://localhost:8080/apis/extensions/v1beta1/namespaces/default/deployments \
-XPOST -H 'Content-Type: application/json' -d@deployment.json
curl -X GET http://localhost:8080/api/v1/namespaces/default/pods
curl http://localhost:8080/apis/extensions/v1beta1/namespaces/default/deployments -XDELETE
curl http://localhost:8080/api/v1/namespaces/default/services/dokuja -XDELETE