Docker is an open source platform for building, deploying, and managing containerized applications.
Containers simplify the delivery of distributed applications and have become increasingly popular as organizations shift to cloud-native development and hybrid multicloud environments.
Docker was created by Salomon Hykes as an internal project in dotCloud presented in 2013 at the PyCon.
The Docker runtime was written in Go, nowadays the biggest contributors to this project have been Google, Microsoft, IBM, Huawei, Red Hat y el Docker Team.
Text
Text file containing the commands used by the user to create an image.
FROM busybox
MAINTAINER Gustavo Gimenez <gimenezanderson@gmail.com>
RUN mkdir /app
ADD build/geo /app
RUN mkdir /app/data
RUN chmod -R 777 /app
EXPOSE 4000
CMD ["./app/geo"]
Most used docker commands
// Información general
man docker // man docker-run
docker help // docker help run
docker info
docker version
docker network ls
// Imagenes
docker images // docker [IMAGE_NAME]
docker pull [IMAGE] // docker push [IMAGE]
// Contenedores
docker run
docker ps // docker ps -a, docker ps -l
docker stop/start/restart [CONTAINER]
docker stats [CONTAINER]
docker top [CONTAINER]
docker port [CONTAINER]
docker inspect [CONTAINER]
docker inspect -f "{{ .State.StartedAt }}" [CONTAINER]
docker rm [CONTAINER]
SSH inside a container
docker pull ubuntu
docker run -it --name ubuntu_example ubuntu /bin/bash
Build an Image
FROM busybox
MAINTAINER Gustavo Gimenez <gimenezanderson@gmail.com>
RUN mkdir /app
ADD build/server /app
RUN mkdir images
ADD images /images
RUN chmod -R 777 /app
EXPOSE 9000
ENTRYPOINT "/app/server"
Dockerfile
// Build image
docker build -t image-server .
// Run it
docker run -d -p 9000:9000 --name server-ex image-server
Commands
Docker Volume
// Run it
docker run -d -p 8080:90 --name volume-server-example -v $(pwd):/usr/share/nginx/html nginx
Using a nginx server
Test Docker Image
FROM ruby:2.3.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN mkdir /app
WORKDIR /app
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
RUN bundle install
ADD . /app
Dockerfile
docker run -it --name sinatra-test sinatra-app rspec spec/app_spec.rb
Run image
Test Docker Image
FROM gusga/sinatra-app:0.1
CMD [ "sh", "-c", "rspec"]
Build image
docker run -it --name sinatra-test sinatra-app rspec spec/app_spec.rb
Run it
docker build -f Dockerfile.test -t sinatra-test-image .
Dockerfile.test
Share Image
FROM ruby:2.3.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN mkdir /app
WORKDIR /app
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
RUN bundle install
ADD . /app
Build image
docker push gust/sinatra-app
Publish
docker build . -t gusga/sinatra-app
Dockerfile file
Rkt
Linux Containers LCX
LXD container hypervisor
Tipo | Software |
---|---|
Clustering/orchestration | Swarm, Kubernetes, Marathon, MaestroNG, decking, shipyard |
Docker registries | Portus, Docker Distribution, hub.docker.com, quay.io, Google container registry, Artifactory, projectatomic.io |
PaaS with Docker | Rancher, Tsuru, dokku, flynn, Octohost, DEIS |
OS made of Containers | RancherOS |