Container Architectures Flashcards
Dockers, Kubernetes, Anthos (127 cards)
What are the technical benefits of containerisation?
1) Portability - Applications / services easily transport between different servers and environments.
2) Less Resources - Efficiency through using far fewer resources than VMs as your are only virtualising the OS rather than the entire infra.
3) DevOps – Bridges the environment and dependency logic between development and production.
4) Teams can create functionality with its own life cycle and scaling policies.
5) Security - Improved security by isolating applications from the host system and from each other.
6) Faster - Faster app start-up and easier scaling.
What are the business benefits of containerisation?
1) Consistency leading to lower cost of development via reduced overhead between development and operation.
2) Loose coupling, avoiding legacy and vendor lock-in
3) Agility
How do you list all docker images?
docker images
How would you go about deleting an old docker image?
docker rmi {image_name}
docker image rm {image_name}
How would you go about running a container from a local docker image in detached mode?
docker run -d {image_name : image_tag}
How would you go listing all running containers on docker?
docker ps
container ls
How would you list docker containers even in exited state?
docker ps -a
How would you go about mapping your dockerhost port to the container port when spinning up a container?
Docker run -d -p {dockerhost_portnumber}:{container_portnumber} {image_name}:{tag_id}
For example:
Docker run -d -p 8080:80 nginx:latest
How would you go about mapping multiple ports on the host when spinning up a container?
Docker run -d -p {{dockerhost_portnumber}:{container_portnumber} -p {dockerhost_portnumber}:{container_portnumber} {image_name}:{tag_id}
For example:
Docker run -d -p 3000:80 -p 8080:80 nginx:latest
How would you run a container in docker with a name?
Docker run –name {name} -d {image_name}:{tag_id}
What is the purpose of docker volumes?
Allows us to MOUNT data between:
1) Host and container
2) Between multiple containers
What command flag would you use to mount files between host and container in docker?
-v {host_destination} :{ conatiner_destination}
How would you go about running commands within a active container in docker?
docker exec -it { container_name } bash
How do you exit the CLI of a “stepped into” container?
ctrl + d
What flag would you use to mount files between two containers in docker?
docker run –volumes-from { target_container_name }
How would you go about building a docker image from a local dockerfile named “website”?
docker build -t website:latest .
Are docker volumes better in dev or prod and why?
Development, for connecting local file system to container file system.
This is not as required prod, as you can use the dockerfile to move files between host and container.
What’s the difference between CMD and RUN within a dockerfile?
RUN is an image build step, the state of the container after a RUN command will be committed to the container image. A Dockerfile can have many RUN steps that layer on top of one another to build the image.
CMD is the command the container executes by default when you launch the built image. A Dockerfile will only use the final CMD defined.
How would you go about taking advantage of caching within docker builds?
Integrated the ADD and COPY commands into the Dockerfile.
The ADD and COPY commands in a Dockerfile allow you to import external files into a Docker image.
If the contents of all external files on the first ADD command are the same, the layer cache will be used and all subsequent commands until the next ADD or COPY command will use the layer cache.
However, if the contents of one or more external files are different, then all subsequent commands will be executed without using the layer cache.
If you would like to reduce the size or resource efficiency of a single container, how would you go about it?
Use an alpine distribution of the container to reduce the image size.
How would you go about tagging a existing docker image to give a version number?
docker tag website:latest website:1.0.0
Where does the word Kubernetes come from?
Greek for “Captain”
Why was Kubernetes invented by Google?
The rise of microservices caused an increased usage of container technologies, because containers offer the perfect host for small, independent and decoupled applications and servcies.
The rise of loosely coupled services resulted in the creation of applications that comprise of 100’s or even 1000’s of containers. Managing this number of containers across multiple environments using just scripts and self-made tools became more complex than managing a monolith.
What benefits does container orchestration offer?
High availability
Automation - Automates deployment, scaling, load balancing, logging and monitoring of containers.
Self-Healing - Automatically replaces unhealthy or failed conatiners.