2. Who am I?
Raül Pérez
@repejota
https://github.com/repejota
https://www.linkedin.com/in/repejota
Lead Software Engineer at @Carrenza
● Managing a small team remotely
from Barcelona.
● Working with DevOPS stuff.
● Still more a dev than an OP.
● Proud to be a #Gopher but I’ve
coded on a bunch of different
languages.
Raül Pérez 20/01/2016
3. What is Docker?
Docker is a tool:
● Based on the original LXC.
● Helps you to containerize your app.
● Handles network between
containers.
● Handles volumes between
containers.
Raül Pérez 20/01/2016
4. What is not Docker?
● Docker are not Virtual Machines!!
● Docker does not offer a single way
to do things:
○ Offers a powerful CLI
○ There is always more than one way to
do the same.
○ Build workflows, adapt it to your existing
pipeline.
Raül Pérez 20/01/2016
5. Docker: Many tools in one
docker
● Main tool.
● Handles containers.
docker-compose
● Orchestrate containers.
docker-machine
● Manage servers ( remote or local ).
Raül Pérez 20/01/2016
6. Docker: docker
● Handles building containers.
● Handles building images.
● Handles running containers.
● ....
● It does not orchestrate.
● It does not help during the
development process.
Raül Pérez 20/01/2016
7. Docker: docker-compose
● It orchestrates containers.
● Handles show each container
connects to other ones.
Raül Pérez 20/01/2016
9. How to use Docker?
Production:
● Uses images
● hub.docker.com
● Everything is built.
● Everything is compiled.
● EASY!
Development:
● Uses the code itself.
● Nothing is build or compiled.
● HARD!
https://github.com/hurrabox
Raül Pérez 20/01/2016
10. How to use Docker? : production
● docker-compose.yml
● 5 containers
○ database
○ redis
○ api
○ front
○ nginx
● This is for production
○ It builds from images
db:
image: postgres
redis:
image: redis
api:
restart: always
image: ulabox/api:latest
links:
- redis
- db
front:
restart: always
image: ulabox/front:latest
links:
- redis
- db
nginx:
restart: always
image: ulabox/nginx:latest
ports:
- "80:80"
links:
- front
- api
Raül Pérez 20/01/2016
11. How to use Docker? : development
● docker-compose-dev.yml
● 5 containers
○ database
○ redis
○ api
○ front
○ nginx
● This is for development
○ It builds from source code
api:
build: ./repos/api
volumes:
- ./repos/api:/src
front:
build: ./repos/front
volumes:
- ./repos/front:/src
nginx:
build: ./repos/nginx
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
Raül Pérez 20/01/2016
12. How to use Docker?
docker-compose -f docker-compose.yml -f dev.yml up -d
● Uses docker composition of services
https://docs.docker.com/compose/extends/
● First use docker-compose.yml
● Second ‘extend’ the service overriding fields with dev.yml
● Do not worry anymore about how to link prod & dev, you just got it. :)
Raül Pérez 20/01/2016
13. How to use Docker? Workflow
● Yes but, how do i work on a
component of my service?
○ Do I need a shared folder?
○ Do I need to ssh to to the container?
○ How can i change/build/restart?
● Well there is no a perfect solution
for this … yet.
Raül Pérez 20/01/2016
14. How to use Docker?
docker-compose -f docker-compose.yml -f dev.yml run <service> <cmd> --service-ports
● Service ports allows you to read dependencies and start the related
containers of the one you choose.
● It executes also CMD overriding the default command.
● You can use it like the normal docker CLI to start a container and expose a
path as a volume.
Raül Pérez 20/01/2016