Docker
Kubernetes – Pod Creation Examples
* Replica 3, Name : nginx-deployment
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80 |
* Create a simple Pod to use as a test environment
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
apiVersion: v1 kind: Pod metadata: name: dnsutils namespace: default spec: containers: - name: dnsutils image: gcr.io/kubernetes-e2e-test-images/dnsutils:1.3 command: - sleep - "3600" imagePullPolicy: IfNotPresent restartPolicy: Always |
* dd
1 |
kubectl apply -f https://k8s.io/examples/admin/dns/dnsutils.yaml |
* cc
*
Ref :
- https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/
- a
- b
- c
- d
Kubernetes
Docker Command Line Examples
Changing directory of the overlay and Docker installation images
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
1) /etc/sysconfig/docker 2) /etc/docker/daemon.json 1) Updating ‘/etc/sysconfig/docker’ file: cat /etc/sysconfig/docker OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false -D -g /home/thiru/docker' g -> specify docker’s root directory 2) Updating /etc/docker/daemon.json [root@docker-host-1 ~]# cat /etc/docker/daemon.json { "graph": "/home/thiru/docker" } |
Docker Shared Mount ( Mount directory from one container to another )
Ex1:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
docker run -v /data/myfolder --name container1 image-name-1 docker run --volumes-from container1 image-name-2 docker run -v myfolder:/data/myfolder image-name-1 docker run -v myfolder:/data/myfolder image-name-2 Building from file # Ubuntu image FROM ubuntu:14.04 for the image to test the use of the other data only volume. docker build -t bitplan/dataonly:0.0.1 -f Dockerfile.data . docker build -t bitplan/dataexample:0.0.1 . |
Docker : Use host networking
Using host networking
If you use the host
network driver for a container,
that container’s network stack is not isolated from the Docker host.
For instance, if you run a container which binds to port 80 and you use host
networking,
the container’s application will be available on port 80 on the host’s IP address.
The host networking driver only works on Linux hosts,
and is not supported on Docker for Mac, Docker for Windows, or Docker EE for Windows Server.
Command Line :
--network host
to the docker container create
command.
In this case,
if a service container binds to port 80, only one service container can run on a given swarm node.
If your container or service publishes no ports, host networking has no effect.