Docker Flashcards
Describe a Pipeline with Docker from app build to deployment.
- Once the code is completed, you commit the code, along with the Dockerfile, to Git or any other version control system
- This should trigger a Continuous Integration like Jenkins Build or AWS Code Build
- Jenkins will build your image based on the Inst in the Dockerfile
- From there, push your image to a Private Docker Repo
- Anyone with access to the repo can pull the image to a dev server, test env or deploy it to production
What is a container? (Conceptually)
a lightweight, standalone, executable package of software that includes everything needed to run an application from configuration to dependencies
Where do containers live?
Public Repositories like Docker Hub
Or Private Repo that can be on-prem or Cloud-based
How did containers improve the application Development process?
Containers provide an isolated environment that can install/run your pre-configured application with one command regardless of your OS
Before containers, there were a lot more steps involved in the setup. Not to mention everyone being in different env lead to inconsistencies.
How did containers improve the application Deployment process?
Now developers and Operations work together to package the application in a container.
Since all the dependencies are pre-packaged. No environmental config is needed on the server - (except for Docker Runtime)
What was the application Deployment process like without the use of containers?
The development team would produce artifacts with instructions on how to install and configure artifacts on the server. It would be up to the operations team to properly interpret instructions and set up the env to deploy the app.
Three main issues with deploying applications before containers?
- The Ops team might misinterpret or disagree with the Dev team’s instructions on how to install and configure artifacts on the server
- Which would create multiple versions of the app as they go back and forth
- Resulting in dependency version conflicts
What are the different components that make up a container?
A container comprises layers of images stacked on top of each other, usually with Alpine Linux at the base.
Alpine is used since it is lightweight and small)
What are the requirements to pull an image from a public repo?
Have Docker installed locally and execute the docker run or docker pull command
No login or authentication is needed.
What is the advantage of containers downloading images in layers?
If you were to download an updated version of the image, only the layers that changed would be downloaded again. Therefore reducing the download time.
What is the difference between an image and a container? (image)
An image is the actual package made up of the application, configurations and start script. This artifact can be moved around at will and as needed.
What is the difference between an image and a container? (container)
When you pull or deploy an image and start it, that creates the container environment that contains the application and all its dependencies
Docker v.s. Virtual Machine?
(Size, Speed)
Size: Docker virtualizes the application layer, while VMs virtualize the application and OS layer. Making Docker images a couple of MB while VMs are in the GB range.
Speed: Being smaller makes Docker easier to start and run time much quicker
Docker v.s. Virtual Machine? (Compatibility)
VMs of any OS type can run on any OS host.
Docker Toolbox is needed to run on non-compatible OS’s (Older Win or Mac versions)
docker ps
docker ps -a
- list all running containers
- list all containers that are stopped and running
What command or flag would you use with docker ps -a to only see a specific image instead of the entire list?
docker ps -a | grep < containername or containerID >
docker images
Will list all the images that are available (not running) on your local system.
The output will show the repo it came from, tag(version), ImageID, date created, & size
docker stop < container_name or container_id >
Once the container stops, you can remove it using which command?
To remove a Docker container, you first have to stop the running container and then delete it:
docker rm < container_name or container_id >
Remove the container w/o stopping it by using:
docker rm -f < container_name or container_id >
docker start < container_name or container_id >
Exp: docker start nginx-container
We can also start it as:
docker start df1c49ee5275
Will start a container that has already been created using docker run or the docker create command
exp: docker create –name < container_name > < image_name >
docker run < image_name >
There are docker create and start commands, but it’s a rare case to create the container and run it later.
In real-world cases, we would create and start the container in one go using the docker run command.
What happens if you pass docker run < image_name > to the terminal, but that image is not available locally?
Docker will pull the image and start the container.
If you don’t specify a version docker will always pull the latest by default.