dependencias de otros servicios •Los Ambientes de Desarrollo, Testing y Producción son generalmente diferentes •Pasar a Producción: Funcionaba bien en mi computador
VM OS Bins/ Libs Bins/ Libs Bins/ Libs App A App A’ App B Server Host OS Container Engine Bins/Libs Bins/Libs App A App A’ App B App B’ App B’ Los contenedores son procesos aislados pero comparten SO, y librerías y binarios VM Container
el Kernel (LXC) Docker Client • Se comunican via API con el Daemon • Es un comando de consola: $ docker Docker Images • La base para crear nuestro container • Son read-only
from the registry docker inspect mongo:latest # list information of the container docker run -p 27017:27017 \ --name my-mongo -d \ mongo:latest # create and start a mongo container docker inspect my-mongo # inspect the running container info docker logs -f my-mongo # tail the log of the container docker stop my-mongo # stop the container docker rm -v my-mongo # remove the container docker rmi mongo:latest # remove the image from the local repo
shows images available logs fetch the logs of a containe inspect return low-level information on a container or image events gets events from container port list port mappings for the container top display the running processes of a container stats display a live stream of container(s) resource usage statistics
# Exec the bash shell, this command gives access to our container docker exec -i -t mycontainer /bin/bash ## You should see now something like: root@<id>:/# apt-get update && apt-get install cowsay -y && \ ln /usr/games/cowsay /usr/bin/cowsay && rm -rf /var/lib/apt/ lists/* •Los cambios hechos en un contenedor se pierden al detener el contenedor •Haciendo un commit a la imagen, estos persisten
$ docker commit mycontainer <yourname>/ubuntu •Revisemos los cambios docker diff mycontainer # shows the added files docker history ubuntu # shows the image history docker history <yourname>/ubuntu # shows the image history •Eliminamos el contenedor $ docker stop mycontainer $ docker rm mycontainer