Tag Archives: docker

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