Docker 101 - From production to development
Post on 13-Apr-2017
199 Views
Preview:
Transcript
Docker 101From production to development
Raül Pérez <repejota@gmail.com>
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
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
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
Docker: Many tools in onedocker
● Main tool.● Handles containers.
docker-compose
● Orchestrate containers.
docker-machine
● Manage servers ( remote or local ).
Raül Pérez 20/01/2016
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
Docker: docker-compose● It orchestrates containers.● Handles show each container
connects to other ones.
Raül Pérez 20/01/2016
Docker: docker-machine● Manages remote servers● Manages virtual machines (
Vagrant )
Raül Pérez 20/01/2016
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
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
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
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
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
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
Thanks!Questions?
top related