Docker swarm
docker swarm is Docker nature cluster manager, with built-in DNS service found mechanism, and load-balancing mechanism. compare to k8s, is a light-weight and easy goers.
create a swarm cluster
|
|
create service
|
|
create overlay network
|
|
in swarm mode, there are three network created by default:
- bridge0, the default network
- docker_gwbridge, local bridge used to connect containers hosted in the same host
- ingress, is a overlay network used in the swarm cluster
however, in swarm mode, the default network for service is bridge, to across physical host, services need go through overlay network.
load balancing
Ingress load balancing
expose Docker service to external network env
Internal load balancing
swarm mode has build-in DNS
Docker compose
docker compose is a manage/build tool to create application, which combine a bunch of micro-services, each of which can be ran as a Docker container.
the docker-compose.yml configure file has to include each micro-service Dockerfile, and the application running scripts.
service startup order
the services defined in docker-compose.yml is not necessary depended to each other, so each serice can up individually, but of course they can has based on each other.
docker-compose.yml
build
path to Dockerfile, can be absolute path or relative (to .yml) path. Compose will buid the image based on
context
sub-choice under build, point to the Dockerfileimage
the image will be used, if not locally, will pull from hub (vs Dockerfile)
containe_name
volumes
path to attached volumes, in the formatHOST:CONTAINER[:access mode]- network_mode
same as docker run --network
init
privileged
- command
override launch command when service contianer start
- environment
set env variables, in the format ENV:value
if only ENV, the value will be derived from host machine
- runtime: nvidia
to suuport nvidia-docker
e.g.
|
|
- stdin_open
std io aviable
- tty
virtual terminal
sample yml from project
a sample yml for web app:
|
|
a sample yml for general app CI:
|
|
docker-machine
docker-machine is a tool to build virtial host when hosted in one physical host or among multi-physical hosts.
ros-docker
in self-driving software stack, ros is often used. and there is a need to deploy ros in docker. next time.