Docker Orchestration – Three tools for orchestrating distributed app with Docker – Docker Machine Tool that provisions Docker hosts and installs the Docker Engine on them – Docker Swarm Tool that clusters many Engines and schedules containers – Docker Compose Tool to create and manage multi-container applications Docker Hub ———————————–
docker images docker run -i -t ubuntu:latest /bin/bash
(stdin ; pseudo terminal) # still running
docker ps
# all the container previously run
docker ps -a
# Detached mode
docker run -d centos:7 ping 127.0.0.1 -c 50
# see output of the container
docker logs <CONTAINER_ID>
# -P flag to map container ports to host ports
docker run -d -P tomcat:7
# -p specifiy ports explicitly
docker run -d -p 8080:80 tomcat:7
#ouvre une nouvelle instance shell du container
docker exec -i -t <CONTAINER_ID> /bin/bash
#liste machine virtuelle
docker-machine ls
#liste l’adresse ip de la machine « default », ce qui sera l’ip d’entrée du container depuis le host
docker-machine ip default
To view all env variables:
docker exec container env
To get one:
docker exec container env | grep VARIABLE | cut -d'=' -f2
# Build an image ============
docker commit <CONTAINER_ID> <app_name>:<tag>
# change docker tag name
docker tag
# Find the MySQL Ip Address in Docker container ( default port is still 3306 )
docker inspect myimage_mysql | grep IPAddress
——- DOCKERFILE ———
docker build -t <app_name>:<tag> <path>
CMD ["ping", "127.0.0.1", "-c", "30"] ENTRYPOINT ["ping"] EXPOSE 80 443
—————
#stop running container
docker stop <container>
#remove stopped container (docker ps -a)
docker rm <container> docker rmi <image>
——— DOCKER COMPOSE —————
docker-compose up docker-compose down docker-compose start / stop
rebuild docker container in docker-compose.yml
docker-compose up -d --force-recreate --no-deps --build nginx
options :
-d Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit. --force-recreate Recreate containers even if their configuration and image haven't changed. --build Build images before starting containers. --no-deps Don't start linked services.