Created: 2023-03-2620:03
What Problem Are We Hoping To Solve?
Originally when you wanted to run any OS as a server you had to have dedicated hardware to run that server. Eventually, Hypervisors came along and allowed for the use of multiple virtual machines on one set of given hardware. This allowed for one set of hardware to be utilized by a couple different operating systems.
The issue with this however is that this setup was really heavy and took a lot of time to boot up, and in comes docker.
virtual machine stack (top-down):
- virtual machines
- hypervisor (VMware)
- hardware
docker stack (top-down)
- containers
- docker-engine
- host OS (ubuntu)
- hardware
What are containers?
- fast
- lightweight
- microcomputers with their own:
- OS
- CPU
- Mem
- Network
- Isolated
Basic Docker Commands
get a docker image
docker pull <image_name>
run docker container
docker run -d -t --name <container_name> <image>
-d
run the container in the background-t
allocate pseudo-TTY
interact with container
docker exec -it <container_name> bash
-i
interactive-t
pseudo-tty
Running Applications In Containers
- first, get an image of the container with the application in it.
- Network Chuck uses:
thenetworkchuck/nccoffee:frenchpress
docker pull thenetworkchuck/nccoffee:frenchpress
- Network Chuck uses:
- then you want to run the containerized application
docker run -t -d -p 80:80 --name nccoffee thenetworkchuck/nccoffee:frenchpress
-t
pseudo-tty-d
run in background-p 80:80
map port 80 on our host to port 80 on the container--name
name the container
Why Docker Containers
- It is super fast!
- all containers use the same kernel
- the kernel is already running on the host os
- lightweight
- only need one kernel
- no hypervisor (heavy)
- Containerized applications will work anywhere
- microservices
- segmenting portions of application
- UI in one container
- db in another container
- etc
References:
- https://www.youtube.com/watch?v=eGz9DS-aIeY