DCA - Exam Preparation
DCA - Exam Preparation
ISSUED BY
Zeal Vora
REPRESENTATIVE
instructors@kplabs.in
Module 1: Important CLI Commands
Scale Swarm Service docker service create --name webserver --replicas 1 nginx
Replicated service will have N number of containers defined with the --replica flag
docker service scale allows us to specify multiple services in the same command.
docker service update command only allows us to specify one service per command.
The communication between containers can be made secured with IPSec tunnels.
● docker system events provide you real-time even information from your server.
● Service Deployment would be in a pending state if the node is drained.
● Service deployments can also be in a pending state due to placement constraints.
● You can further inspect the task to see more information.
Routing mesh enables each node in the swarm to accept connections on published ports for
any service running in the swarm, even if there’s no task running on the node.
To prevent the scheduler from placing tasks on manager nodes, set the availability for the
manager node to Drain
Module 11: Join Tokens in Swarm
Join tokens are secrets that allow a node to join the swarm.
There are two different join tokens available, one for the worker role and one for the manager
role.
You can use the --force option on a manager to remove it from the swarm.
Only use --force in situations where the swarm will no longer be used after the manager leaves,
such as in a single-node swarm.
Module 13: Service Discovery in Swarm
Docker uses embedded DNS to provide service discovery for containers running on a single
Docker engine and tasks running in a Docker swarm
The docker system df command displays information regarding the amount of disk space used
by the docker daemon.
Module 15: System Events in Docker
Use docker system events to get real-time events from the server. These events differ per
Docker object type.
It can also show you a list of volumes that are attached to the container.
Module 17: Container vs Virtual Machines
The container uses the resource of the host operating system (primarily the kernel)
dockerd is a persistent process that manages containers. Docker uses different binaries for the
daemon and client. To run the daemon you type dockerd
For specifying the configuration options, you can make use of daemon.json file.
● ADD
● COPY
● RUN
● ENTRYPOINT
● WORKDIR
● ENV
● VOLUMES
● CMD
● HEALTHCHECK
The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT, COPY
and ADD instructions that follow it in the Dockerfile
Sample Snippet:
Module 24: Format Option
The format option allows us to format the output based on various criteria that we have defined
with the command
The filter option allows us to filter output based on the condition provided.
Sample Use-Case:
By default, the docker will not allow you to perform the operation with an insecure registry.
You can override by adding the following stanza within the /etc/docker/daemon.json file
{
"insecure-registries" : ["myregistrydomain.com:5000"]
}
Module 27: Pushing an image to a private repository
Description Commands
Push Image to Private Repository with DNS name of docker tag ubuntu:latest example.com/myrepo:ubuntu
example.com
Save Container to TAR Archive (Data is also flattened) docker export my-container > container.tar
The docker load command will load an image from a tar archive
You can use the -e, --env, and --env-file flags to set simple environment variables in the
container you’re running or overwrite variables that are defined in the Dockerfile of the image
you’re running.
docker run --env VAR1=value1 --env VAR2=value2 ubuntu env | grep VAR
Module 30: EXPOSE Instruction
The EXPOSE instruction informs Docker that the container listens on the specified network
ports at runtime.
It functions as a type of documentation between the person who builds the image and the
person who runs the container, about which ports are intended to be published.
HEALTHCHECK instruction in Docker allows us to tell the platform on how to test that our
application is healthy.
That uses the curl command to make an HTTP request inside the container, which checks that
the web app in the container does respond.
It exits with a 0 if the response is good, or a 1 if not - which tells Docker the container is
unhealthy.
Module 32: Tagging Docker Images
Syntax:
Example Snippet:
Dangling Images = Image without Tags and Image not referenced by any container
If your image is available on a private registry which requires login, use the --with-registry-auth
flag with docker service create, after logging in.
Docker uses a layer cache to optimize the process of building Docker images and make it
faster.
Control Groups (cgroups) is a Linux kernel feature that limits, accounts for, and isolates the
resource usage (CPU, memory, disk I/O, network, etc.) of a collection of processes.
By default, users with read and write access can overwrite tags.
To prevent tags from being overwritten, we can configure the repository to be immutable.
Caches are transparent to users since users still log in and pull images using the DTR URL
address. DTR checks if users are authorized to pull the image, and redirects the request to the
cache.
Module 42: DTR Architecture
You can configure the Docker Trusted Registry (DTR) to automatically delete unused image
layers, thus saving you disk space.
Docker Trusted Registry is designed to scale horizontally as your usage increases. You can add
more replicas to make the DTR scale to your demand and for high availability.
If your DTR deployment has multiple replicas, for high availability, you need to ensure all
replicas are using the same storage backend.
You can monitor the status of UCP by using the web UI or the CLI. You can also use the _ping
endpoint to build monitoring automation.
Module 46: Orchestrator Types in UCP
When you install Docker Enterprise, new nodes are managed by Docker Swarm, but you can
change the default orchestrator to Kubernetes in the administrator settings.
You can configure DTR to use an external storage backend, for improved performance or high
availability.
● Local:
● NFS
● Bind Mount
● Volume
● Cloud Storage Provider:
● AWS S3
● Azure
● Google Cloud
You can configure DTR to automatically post-event notifications to a webhook URL of your
choosing
This driver removes the network isolation between the docker host and the docker containers to
use the host’s networking directly.
● Default in Swarm.
● Allows containers across host to communicate with each other.
● Communication can be encrypted with --opt encrypted option.
● Do not confuse, -o is same as --opt
You don’t need to create the overlay network on the other nodes, because it will be
automatically created when one of those nodes starts running a service task which requires it.
● Publish List (-p) will publish a list of ports that you define. [-p 80:80]
● Publish All (-P) will assign random ports for all exposed ports of the container.
● -P will map the container port to a random port above 32768
If you want to completely disable the networking stack on a container, you can use the none
network.
This mode will not configure any IP for the container and doesn’t have any access to the
external network as well as for other containers.
Module 54: Configuring Docker for External DNS
Docker Container’s DNS configuration is taken from the host’s /etc/resolv.conf DNS settings for
containers be customized via daemon.json file.
{
“dns”: [“8.8.8.8”, “172.31.0.2”]
}
Depending on the permission associated with the user, you can now execute docker swarm
commands from your remote machine that take effect on the remote cluster.
Module 57: Docker Content Trust
Example Dockerfile:
FROM myubuntu:latest
RUN apt-get install net-tools
CMD[“bash”]
This is a cluster management command, and must be executed on a swarm manager node.
When you grant a newly-created or running service access to a secret, the decrypted secret is
mounted into the container in the following path:
/run/secrets/<secret_name>
We can also specify a custom location for the secret.
When you create a swarm by running docker swarm init, Docker designates itself as a
manager node.
By default, the manager node generates a new root Certificate Authority (CA) along with a key
pair, which are used to secure communications
Module 62: Certificates for Each Node
Each time a new node joins the swarm, the manager issues a certificate to the node.
By default, each node in the swarm renews its certificate every three months.
When the operator executes docker run --privileged, Docker will enable access to all devices on
the to allow the container nearly all the same access to the host as processes running outside
containers on the host.
Module 64: Roles in UCP
Example:
If you update the image of deployment from nginx to apache, not all of the pods in deployments
are brought down together.
You can specify maxUnavailable and maxSurge to control the rolling update process
A Secret is an object that contains a small amount of sensitive data such as a password, a
token, or a key.
Since an internal cluster IP is assigned, it can only be reachable from within the cluster.
If the service type is NodePort, then Kubernetes will allocate a port (default: 30000-32767) on
every worker node.
A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an
administrator or dynamically provisioned using Storage Classes
Module 78: Dynamic Volume Provisioning
The dynamic provisioning feature eliminates the need for cluster administrators to pre-provision
storage. Instead, it automatically provisions storage when it is requested by users.
Within the claim, the user needs to specify the size of the volume along with access mode.
Developer:
Requests and Limits are two ways in which we can control the amount of resource that can be
assigned to a pod (resource like CPU and Memory)
Kubernetes Scheduler decides the ideal node to run the pod depending on the requests and
limits.
If your POD requires 8GB of RAM, however, there are no nodes within your cluster which has
8GB RAM, then your pod will never get scheduled.
Labels are key/value pairs that are attached to objects, such as pods.
Show me all the pods which have a label where env: production
For SVC in ns1, POD in the same namespace can communicate with just A. Pod in ns2
namespace can make use of a.ns1 <service.namespace>
Module 85: Taints and Tolerations
Taints are used to repel the pods from a specific node.
In order to enter the taint worker node, you need a special pass. This is referred to as
Toleration.
For example, the application is running but it is still loading it’s large configuration files from
external vendors.
In such a case, we don’t want to kill the container however we also do not want it to serve the
traffic.
Module 87: Reclaim Policy
PersistentVolumes can have various reclaim policies, including “Retain”, “Recycle”, and
“Delete”.
To request a larger volume for a PVC, edit the PVC object and specify a larger size. This
triggers the expansion of the volume that backs the underlying PersistentVolume
Module 89: Storage Classes
A StorageClass provides a way for administrators to describe the "classes" of storage they offer.
Each StorageClass contains the fields provisioner, parameters, and reclaimPolicy, which are
used when a PersistentVolume belonging to the class needs to be dynamically provisioned.
Module 90: Volume Expansion Steps
1. Enable Volume Expansion in Storage Class (allowVolumeExpansion: true)
2. Resize the PersistentVolumeClaim
3. Restart the POD.
When PVC is deleted, the PersistentVolume still exists and the volume is considered
"released".
It is not yet available for another claim because the previous claimant's data remains on the
volume.
● Volume
● Persistent Volume
●
Kubernetes volume exists only while the containing pod exists. Once the pod is deleted, the
associated volume is also deleted. Does not exists outside of the pod’s lifecycle. Used for
storing temporary data.
Kubernetes persistent volumes remain available outside of the pod lifecycle. PV will remain
even after the pod is deleted
--interval=30s
To list the PODS from all the namespaces in Kubernetes, the following commands needs to be
used:
Multi-Stage builds allow users to use artifacts from one image to another.
Join Our Discord Community
We invite you to join our Discord community, where you can interact with our support team for
any course-based technical queries and connect with other students who are doing the same
course.
Joining URL:
http://kplabs.in/chat