Docker micro services
when deploy an application(lg-sim) to swarm cluster as a service, which is defined in a/the manager node, the manager node will dispatch units of work as taskes to worker nodes.
when create a service, you specify which container image to use and which commands to execute inside runing containers. In the replicated services
, the swarm manager distributes a specific number of replica tasks among the nodes based upon the scale you set in the desired state. For global services
, the swarm runs one task for the service on every available node in the cluster.
Docker swarm CLI commands
|
|
delete unused Docker network
as Docker network may confuse external when access to the local network interfaces, sometimes need to remove the docker networks.
|
|
the above scripts will delete the unused(non-active) docker network, then may still active docker related networks, which can be deleted through:
|
|
docker service create –name web_server –replicas=2 httpd
docker service ps web_server
access service only on host machine through the Docker IP
curl 172.17.0.1
docker service update –publish-add 8080:80 web_server
access service externally
curl http://hostmachineIP:8080
docker service create –name web_server –publish 880:80 –replicas=2 httpd
curl 172.17.0.1:880
curl localhost:880
curl 192.168.0.1:880
curl 192.168.0.13:880 #the other docker node
docker service create –name web_s \
–publish 8080:80 \
–mount “type=volume, volume-driver=rexray, source=web_data, target=/usr/local/apache2/htdocs” \
httpd
docker exec -it containerID
ls -ld /usr/local/apahce2/htdocs
chown www-data:www-data
test visit
curl http://192.168.0.1:8080
docker inspect containerID
```
source
reprensents the name of data volume, if null, will create newtarget
reprensents data volume will be mounted to /usr/local/apache2/htdocs
in each container
in RexRay, data volume update, scale, failover(when any node crashed, the data volume won’t lose) also be taken care.