2. What is Docker?
Pack, ship, and run any application as a lightweight, portable, self-sufficient
container that runs virtually anywhere (James Bottomley, CTO, Parallels)
3. What is Docker?
Is not a virtualization technology
Built on top of LXC (Linux Containers)
https://en.wikipedia.org/wiki/LXC
4. Containers vs Virtual Machines
Hardware
Virtual machine
Host OS
Hypervisor
Guest OS Guest OS
Libraries Libraries
Application 1 Application 2
5. Containers vs Virtual Machines
Hardware
Virtual machine
Host OS
Hypervisor
Guest OS Guest OS
Libraries Libraries
Application 1 Application 2
Hardware
Container
Host OS
Docker engine
Libraries Libraries
Application 1 Application 2
X
6. Reasons to use
at least for development
Consistent development environments for your entire team.
All developers use the same OS, same system libraries, same language runtime,
no matter what host OS they are using (even Windows if you can believe it).
7. Reasons to use
at least for development
The development environment is the exact same as the production environment.
Meaning you can deploy and it will “just work”.
Deployment is easy. If it runs in your container, it will run on your server just the
same. Just package up your code and deploy it on a server with the same image
or push a new Docker image with your code in it and run that new image.
8. Reasons to use
at least for development
You only need Docker to develop. You don’t need to install a bunch of language
environments on your machine. Want to run a Ruby script but don’t have Ruby
installed? Run it in a Ruby Docker image.
Can use multiple language versions without having to resort to all the
hackarounds for your language (python, python, ruby, ruby, java, node).
9. The Copy-on-Write Mechanism
When we launch an image, the Docker engine does not make a full copy of the
already stored image. Instead, it uses something called the copy-on-write
mechanism. This is a standard UNIX pattern that provides a single shared copy of
some data, until the data is modified.
Because of the copy-on-write mechanism, running containers can take less than
0.1 seconds to start up, and can occupy less than 1MB on disk. Compare this to
Virtual Machines (VMs), which can take minutes and can occupy gigabytes of disk
space, and you can see why Docker has seen such fast adoption.
22. Application start
docker-compose up
*NOTE: Your docker machine's ip is 92.168.99.100, to make sure:
docker-machine ip docker
Point browser to http://192.168.99.100:3000
23. Useful commands
# ssh inside container
docker-compose run app bash
# run specs/anything inside container
docker-compose run app bundle exec rspec
# showdown containers
docker-compose down