You are on page 1of 4

Instalar docker en ubuntu 16.

04

1. Instalación de Docker

$ sudo apt update

$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-


keys 58118E89F3A912897C070ADBF76221572C52609D

$ sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-


xenial main'

$ sudo apt update

$ apt-cache policy docker-engine

Output of apt-cache policy docker-engine


docker-engine:
Installed: (none)
Candidate: 1.11.1-0~xenial
Version table:
1.11.1-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main
amd64 Packages
1.11.0-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main
amd64 Packages

$ sudo apt-get install -y docker-engine

$ sudo systemctl status docker

Output
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled;
vendor preset: enabled)
Active: active (running) since Sun 2016-05-01 06:53:52 CDT; 1
weeks 3 days ago
Docs: https://docs.docker.com
Main PID: 749 (docker)
2. Comprobar el funcionamiento de docker

$ docker run hello-world

Output
Hello from Docker.
This message shows that your installation appears to be working
correctly.
...

3. Instalar Wordpress con docker

$ docker run -e MYSQL_ROOT_PASSWORD=”tu clave” -e MYSQL_USER=wpuser


-e MYSQL_PASSWORD=”tu clave” -e MYSQL_DATABASE=wordpress_db -v
/opt/wordpress/database:/var/lib/mysql --name DB -d mariadb

$ docker run -e WORPRESS_DB_USER=wpuser -e


WORDPRESS_DB_PASSWORD=”tu clave” -e
WORDPRESS_DB_NAME=wordpress_db -p 80:80 -v
/op/wordpress/html:/var/www/html --link DB:mysql --name wp_local -d
wordpress

4. Como usar docker

Buscar una imagen en especial

$ docker search Ubuntu

El script buscara en Docker Hub una lista de todas las imágenes cuyo nombre
coincida con la búsqueda. Nos mostrara algo parecido a esto:

Output
NAME DESCRIPTION
STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux
operating s... 3808 [OK]
ubuntu-upstart Upstart is an event-based
replacement for ... 61 [OK]
torusware/speedus-ubuntu Always updated official Ubuntu
docker imag... 25 [OK]
rastasheep/ubuntu-sshd Dockerized SSH service, built on
top of of... 24 [OK]
ubuntu-debootstrap debootstrap --variant=minbase --
components... 23 [OK]
nickistre/ubuntu-lamp LAMP server on Ubuntu
6 [OK]
nickistre/ubuntu-lamp-wordpress LAMP on Ubuntu with wp-cli
installed 5 [OK]
nuagebec/ubuntu Simple always updated Ubuntu
docker images... 4 [OK]
nimmis/ubuntu This is a docker images different
LTS vers... 4 [OK]
maxexcloo/ubuntu Docker base image built on Ubuntu
with Sup... 2 [OK]
admiringworm/ubuntu Base ubuntu images based on the
official u... 1 [OK]

Si deseamos descargar con anterioridad una imagen usaremos

$ docker pull

Visualizar las imágenes instaladas

$ docker images

Visualizar los contenedores detenidos

$ docker ps -a

Visualizar los contenedores que están corriendo

$ docker ps

Corren un contendor

$ docker run “nombre de la imagen

Detener un contenedor

$ docker stop “nombre del contenedor”

Borrar un contenedor
$ docker rm “nombre o id de contenedor”

Ejecutar un contenedor de forma interactiva

$ docker run -it ubuntu

You might also like