Tag Archives: devops

Docker tips

En este post se incluyen una revisión muy sencilla y un conjunto de comandos y acciones relacionadas con el uso de Docker. Para más información, consultar en:

https://docs.docker.com/engine/docker-overview/

https://training.docker.com/

https://veggiemonk.github.io/awesome-docker/

Containers

Running a container

Pull an image from the Docker registry

List the content of the downloaded Docker images

Run commands on a launched container

Launch container in interactive mode

List running containers (and ran)

Images

Inspect an image

Download and run image in one goal

Stop and remove container

Run container in detached mode and provide details

--name --> Name to the container

-e --> Pass variables

-d --> detached mode

-P --> publish ports to docker container host

-p 8888:80 --> Relate port 80 to 8888 in docker host

Image types

Base

  • OS images

Child

  • Based on a base image

Official

  • Certified by Docker

User

  • User created images (from base, usually)

Create a new image (user image)

Create a docker file (Dockerfile)

Build the image

-t –> image tag

. –> directory where Dockerfile is present

Swarm stack

Init swarm manager

Docker compose files (docker-compose.yml)

Deploy the stack

Join swarm

List nodes

List services

Inspect services

Scale up or down the service

Disable/Enable nodes

List deployed tasks

Leave the swarm

Remove stack

Inspect the container

Persist de data

In the host, via de docker-compose file:

Via de Docker file:

The /data will be created on the host as well:

Using the –v option

  • Create and mount
  • Mount

Using the Volume API

  • Create the volumen on the host

Mount it and use it within a container

Docker network drivers (default and created)

  • Bridge support only a single node
  • Overlay support multiple nodes

Create overlay network

Inspect network

Run container within network

By default, bridge network driver is used

Connect an existent container to an existent network

Service discovery

Docker info

Use Docker API to communicate with Docker

Upgrade/downgrade to/from manager

Docker swarm visualizer

http://jpetazzo.github.io/orchestration-workshop/#118

 

Ansible tips

Este post se limita a incluir algunas notas sobre el uso de Ansible y en particular sobre la realización de un tutorial paso a paso sobre la aplicación del mismo, incluyendo los conceptos más básicos.

Inventory file

Ejecuta comandos

Módulos (plugins)

Obtiene información sobre los nodos del inventario

Fichero de inventario, agrupaciones

Variables en fichero de inventario

Playbooks

Registra resultado de tareas y ejecuta en función de su valor

Iteraciones en playbooks

Usar tags en playbooks

Jinja templates

And in the playbook

Lanza varios playbooks

Variables para hosts y para grupos

Se pueden usar en templates

Roles

Se lanzan los roles desde el playbook principal

Estructura de los roles

roles
|
|_some_role
|
|_defaults
|   |
|   |_main.yml
|   |_…
|
|_files
|   |
|   |_file1
|   |_…
|
|_handlers
|   |
|   |_main.yml
|   |_some_other_file.yml
|   |_ …
|
|_meta
|   |
|   |_main.yml
|   |_some_other_file.yml
|   |_ …
|
|_tasks
|   |
|   |_main.yml
|   |_some_other_file.yml
|   |_ …
|
|_templates
|   |
|   |_template1.j2
|   |_…
|
|_vars
|
|_main.yml
|_some_other_file.yml
|_ …

Referencias

https://www.ansible.com/get-started

https://www.ansible.com/how-ansible-works

https://www.ansible.com/webinars-training/introduction-to-ansible