marp | theme | style |
---|---|---|
true |
gaia |
section.lead h1 {
text-align: center;
}
section.middle li{
text-align: center;
}
|
- Containers: They are sealed, self-contained units of software that have everything needed to run a service. What you should know(Viewed)
https://docs.docker.com/get-docker/
- Image -> running container
docker run docker-name
docker ps
-> get information on running container- image is fixed and does not change
- running container -> image (files are stored in stopped container)
docker ps -a
all containerdocker ps -l
last container- topped container has the software installed in it
- docker commit -> container to new image
- Run bash image
docker run -ti ubuntu:latest bash
- create and give images name
- Run processes in containers
- containers have a min proceed
- one main process that has name
- -d run detached container in the background
Registries in detail
-
Kernel : controls and organizes storage, programs and so. allocate resources and so on
-
docker manges kernel
-
cgroup to group process together
-
can be client and server
-
docker control socket
docker run -ti --rm -v /var/run/docker.sock docker sh
- docker comose is a tool for defining and running multi-container Docker applications using single configuration file
- declarative procedure to execute
- they allow you to define a set of services that make up your app
- configuration are self documenting ans easy to manage
- create a configuration file in
yml
format - name it
docker-compose.yml
- ymal: Yet Another Markup Language, a human-readable data-serialization language used for configuration files
- many images are available on docker hub
version: '3.7' # version of docker compose
services: # services to run
store: # name of service
build: . # image to use, current directory
database:
image: postgres:latest # this will be pulled from docker hub
All docker compose commands are run from the directory containing the docker-compose.yml
file
docker-compose up
- start the services # build -> create -> start- specify the service name to start only that service
docker-compose up store
- specify the service name to start only that service
docker-compose down
- stop the services, and delete all running containers # stop -> removestop & rm
docker-compose ps
- list the servicesdocker-compose logs
- show the logsdocker-compose exec
- run a command in a servicedocker-compose build
- build the servicesdocker-compose restart
- restart the services # stop -> startstop & start
docker-compose --help
- show the help
-
build arguments are used to pass values to the build process
-
environment variables are used to pass values to the running container
-
to specify a build argument, use the
--build-arg
flag- we will use
context
to pass the build argument- and add arguments using
arg
in theDockerfile
- and add arguments using
- we will use
-
to specify an environment variable, use the
environment
key in thedocker-compose.yml
file- we will use
environment
to pass the environment variable- and add environment variables using
env
in theDockerfile
- and add environment variables using
- we will use
version: '3.7'
services:
store:
build:
context: .
args:
- BUILD_DATE=${BUILD_DATE}
- VCS_REF=${VCS_REF}
- VERSION=${VERSION}
environment:
- BUILD_DATE=${BUILD_DATE}
- VCS_REF=${VCS_REF}
- VERSION=${VERSION}
- target: the path inside the container where the volume will be mounted
volume
is a directory on the host machinesource
is the path to the directory on the host machine- where the dump is
source = /home/username/dump
./
is the current directory../
is the parent directory, one level above doc config file/
is the root directory
ro
is read-onlyrw
is read-write setting source and target to the same path will mount the volume in the same path inside the containersource:taget:mode
volumes:
- ./dump:/dump:rw
- named volumes are created by docker, name store as Qasim Store
volumes:
- store:/dump:rw
- qasim-store:/dump:rw
volumes:
qasim-store:
ports
is the port on the host machine- each container has its own network stack, so the ports on the host machine are not the same as the ports inside the container
- for qasim-store, the port inside the container is 80, but the port on the host machine is 8080
ports:
- 8080:80 # host:container {from port to port}
depends_on
is used to set up the order in which the services are started- docker compose up will start the services in the order they are defined in the
docker-compose.yml
file
depends_on:
- database
- Ethernet : move frame on wire of wifi
- IP layer : move packets on local network
- routing : forwards packets between networks
- ports: address particular program on a computer
- bridges -> virtual network on computer
- controls the ethenes layer
- docker builds bridges to create virtual network
- Routing -> moving packets
- create fireball rule moves between network
docker run -ti --rm --net=host --privileged=true ubuntu bash
apt-get update
apt-get install iptables
Exposing port is essentially port forwarding
- process init 1-> to many process
- shell -> runs other process -> continuer vanishes Intro to orchestration
-> docker run -ti --rm --name qasim ubuntu bash
-> docker inspect --format '{{.State.Pid}}' qasim
3134
-> docker run -ti --rm --privileged=true --pid=host ubuntu bash
root@e63d21be00c6:/# kill 3134
root@99fb3caf034e:/# exit?
- actual storage
- forms in logical groups
- filesystem : which file belongs where
- COWS!!! -> copy on write
- base image -> write stuff container sees it with changes no change to the image
- like a file system layer on the image !!! COW COPY ON WRITE
- managing cows
- layers -> splits them to gzip files and then puts them on container
- containers are indigent of storage engine
- some have limited layers
- get the right mount order correct