kerDoc Flashcards
What is a Container?
A way to package applications with all the necessary dependencies and configuration they need
What is a Portable Artifact?
Easily shared and moved around
What is a benefit of Containers?
Makes development and deployment more efficient
Where do Containers live?
In storage, in a Container Repository
Is there a public repository for Docker?
Yes, DockerHub
What types of things are usually in a Container?
Code - Node, .NET, Python
Databases
Storage?
If a technology already exists, should you make your own Docker for it?
Only if you want a lot of customization. Thee is likely already an official Docker container for every tech out there
What is a benefit of Containers?
Every dev has to install all the tech they need on their pc, and configure them for their local environment
Are Containers cross platform?
Yes
Is a container its own isolated environment?
Yes
Do containers automatically update and upgrade any tech they contain?
No
You can pick which specific version you want to run, and it will never change
Can you run all the tech in a Docker with one line of code?
No, you have to run one each
You can only run one Docker at a time on a pc
False, you can run several, even several different versions of the same tech, e.g. Postgres 9.6, Postgres 10.17
Developers often work with which group of people on containers?
Operations
What environmental configurations are needed on server?
Only Docker Runtime
Containers contain layers of what?
images (software)
For example, the Linux Base Image
What Linux base image is often used in containers?
alpine
Where is the Application layer, usually?
Application image on top
What would you type in the terminal to get a Docker Container to pull postgres 9.6?
docker run postgres:9.6
When you tell Docker to run a container and it is not installed locally, Docker will download it and start it
What is an advantage of using Layers?
When a dev wants to update some tech in a container, Docker will only download the layers of that tech that have changed
How would you run a docker file for postgres9.6 and create a superuser password from the terminal?
docker run -e POSTGRES_PASSWORD = mypass
How would you check to see what all containers are running from the terminal?
docker ps
Explain the difference between a Docker Image and a Docker container
Docker Image - The actual package, all the code and tech. It is considered an artifact. It does not run
Docker Container - After you pull an Docker Image and start it in your local environment, a container environment is created. A Docker Container is something that is currently running
Where are Docker Images stored locally on Windows?
C:\ProgramData\DockerDesktop ???
/var/lib/docker is mounted on the persistent Virtual Disk of the VM which is under C:\Users\Public\Documents\Hyper-V\Virtual hard disks ???
What command can you run to see your local Docker configuration?
docker info
What 2 layers do OS’s have?
OS Kernel
Applications
What does an OS Kernel control?
Hardware
Is there a different Kernel for every distribution of Linux?
No. Only 1
What part of an OS does a Virtual Machine virtualize?
Applications layer and OS Kernel
What part of an OS does a Docker virtualize?
Applications layer
Does a Virtual Machine use a host kernel?
No, it spins up its own
Typically, are Docker Images or Virtual Machines smaller
Docker Images
Docker Images = MBs
Virtual Machine= GBs
typically
Does a Virtual Machine start faster than a DI?
no way
Can a Virtual Machine or a DI run any OS on any OS host?
Virtual Machine
What can you use to run a Linux DI on Windows
Docker Toolbox
What version of Windows and after do you not need to use Docker Toolbox?
Windows 10
Docker Quickstart Terminal?
it is
Does Docker use the local host’s file system?
No, it creates its own virtual file system
What command can you use to see all Docker Images you have on your pc?
docker images
If you don’t chose a specific version of Docker Image to pull, what happens?
You will pull the latest version
What is one way to stop a running Docker Container?
Ctrl+c
What is detach mode and how can you run it?
When you don’t run Docker in detach mode, when you run a container, the terminal becomes unusable and you have to open another terminal. Detach allows us to keep using the same terminal
docker -d postgres
If some part of your Docker container crashes and you need stop and restart the whole thing, how would you do that?
docker stop (Docker Image ID)
docker start (Docker Image ID)
How can you get a list of all Docker containers running and not running?
docker ps -a
Create binding between a port that your host machine has and the container
yep
If you are running 2 Images simultaneously, can you have them listening to the same port
Yes, as long as you bind them to a different port on your host machine
some-app://localhost:3000
some-app://localhost:3001
How would you bind the container port (6379) to the local pc port (3000)
-p (host port):(container port)
docker run -p 3000:6379 postgres
How can we stop all Containers that are running?
docker kill $(docker ps -q)
The docker ps command will list all running containers. The -q flag will only list the IDs for those containers
How would you clean up any resources — images, containers, volumes, and networks — that are dangling (not associated with a container)
docker prune
how would you remove a specific docker image?
docker rm (Docker Image ID)
Remember, you can use docker ps -a to see all running AND non-running containers
How do you get the logs for a specific container?
docker logs (Docker Container ID)
For most Docker commands you can use the Docker Container ID, or?
the Docker name, listed in docker ps
How can you chose your own name for a Docker Container?
docker run –name (my-name) (image)
How would you access a terminal inside a running container?
docker exec -it (Docker Container ID) /bin/bash
In Bash, how do you print the working directory?
pwd
In Bash, how do you navigate to the home directory?
cd /
In Bash, how do you list all files in a directory?
ls
lowercase LS
In Bash, how would you print the environmental variables?
env
If you’re in a terminal inside the container, how do you get back out to the original terminal?
exit
When you go into a terminal inside a container based on linux, will you have all linux commands?
No
How does docker run differ from docker start?
docker run starts a new container
docker start will only restart a stopped container
If you only want to download an image, and not run it, how would you do that?
docker pull postgres
Does a Docker Network access the internet?
No. It is an isolated virtual network
Which of the following do you need to communicate with a container in the Docker Network?
localhost
port number
Containers in the Docker Network can talk to each other using just the container names
How do you list all the Docker Networks?
docker network ls
How do you create your own network in the Docker Network?
docker network create (chosen network name)
How would you run a file named server.js with node from the cli
node server.js
what is the protocol, uri usually
localhost:(port number)
How would you display just the last log entry?
docker logs –tail 1 (image ID)
docker logs -f (Image ID)
how run in detach?
What is Docker Compose
A structured way to contain common docker commands
Do you have to create a new network manually when using Docker Compose?
Nope
How do you start containers with Docker Compose and yaml?
docker compose -f mongo.yaml up -d
docker-compose -f mongo.yaml up
what does -f mean?
excelipty refercnng a file a file
docker-compose -f mongo.yaml up
what does up mean?
up will start all the containers in the yaml
When you restart a container, what happens to the data?
When you restart a container, everything you configured in that container is gone. There is no data persistence
How would you use docker compose to stop all containers?
docker-compose - (filename.yaml) down
Jenkins
Builds Docker Files (Images)
What is a Docker File?
a Blueprint for building images
Can you execute any Linux commands using RUN in a Dockerfile?
Yes
If you create a directory with a dockerfile, does that directory get created on your host pc?
No
COPY in dockerfile
Executes on the HOST machine
What does the CMD do
can you only have CMD per dockerfile? yes only 1
entrypoint command
it runs start the app inside the container
CMD[“node”, “server.js”]
What is alpine?
the lightest weight base
Can you name a dockerfile anything you want?
No, it must be naemed “Dockerfile” (with no extension)
How do you build an image with a Dockerfile?
docker build -t my-app:1.0 .
. = current directory, -t = ?
When you change a Dockerfile what do you have to do for the changes to take effect?
Rebuild the image
Docker rm vs docker rmi
docker rm removes the container
docker rmi removes the image
What are 2 types of interactive terminals we can access inside the container?
/bin/bash
/bin/sh
Docker push be written like
tag the image on azure
Docker tag be written like
tag the image based on on azure
docker tag my-app:1.0 (Azure URI and name of image):1.0
What must you do before you can push an image?
tag it
When you tag an image does it make a copy or alter the original?
makes a copy
If you have pushed an image, and later you change it, what are the steps to update it in the repository?
docker build -t my-app:(new version number) (path to docker file, usually “.”)
docker tag my-app:()new version number) (old version URI):(new version number)
docker push (old version URI):(new version number)
deployment
lurn bout it
docker inspect
give you info
Typically, are private image names or public image names longer?
private, as they often include URIs
What is a Docker Volume?
A folder on the local host files system is mounted into the virtual file system
Basically how do Docker Volumes work?
When changes are made to the DB inside the container, they are copied over to the host machine
What are the 3 types of Docker Volumes?
sum
Anonymous Volumes
Named Volumes
How would you create a Docker Volume where you want to let docker decide where the Host Volume will be saved from the CLI?
docker run -v (container volume path)
What is the benefit of a Named Volume?
You can reference the volume by name, you don’t have to use the full path
How would you create a Named Volume
docker run -v name:(path)
How would you create a Named Volume?
docker run -v name:(container volume path)
How would you check
docker system df
docker system prune -a
Look up online the default places where containers save their data
double check with
docker exec -it (image) /bin/bash
and then ls
When a container completes startup, it runs the following command to ready the custom container image:
docker ____ –name balanced-container company-image
create
When the load balancer detects high usage, it signals the virtual machine to make the container available for use. The VM runs the following command:
docker ____ balanced-container
start
The load balancer detects that a container has been underutilized for more than 15 minutes. It signals the VM to suspend the container to conserve CPU resources. The VM runs the command:
docker ____ balanced-container
pause
Finding an increased load again, the load balancer signals the VM to awaken the container. The VM runs the command:
docker ____ balanced-container
unpause
After an hour of underutilization, the load balancer signals the VM to gracefully end all processes in the container to conserve RAM resources. The VM runs the command:
docker ____ balanced-container
stop
Gracefully end all processes in the containers
docker-compose stop
Remove the containers and their anonymous volumes
docker-compose rm -v