This is an introduction to Docker & Ansible. It shows how Ansible can be used as orchestration too for Docker. There are 2 real world examples included with code examples in a Gist.
14. What is Docker?
❖ Open Source Project started in March 2013
❖ From the makers of dotCloud (PaaS).
❖ Received $162 Million Funding.
❖ Community grows rapidly!
15. What is Docker?
❖ Tiny VM (25 MB)
❖ Linux based - LXC Interface / libcontainer
❖ Own Namespaces and Cgroups!
❖ Shared resources with host system.
❖ Changes changed in Layers. Similar to Git!
❖ Originally not for Windows & Mac ! But …
->https://docs.docker.com/installation/windows/
-> https://blog.docker.com/2016/03/docker-for-mac-windows-beta/
16. Build - Ship - Run
Docker-Hub
Build RUN
RUN
RUN
docker push
docker pull
Server Farm Production
23. Fetch a Docker Image
> docker pull reiz/nginx:1.0.0
Download docker image reiz/nginx:1.0.0 from Docker Hub to local
Docker repository.
24. Run a Docker Container
> docker run reiz/nginx:1.0.0
Creates a Docker container out of the Docker image reiz/nginx:1.0.0.
It runs the nginx process.
30. Mount a Volume
> docker run -v/mnt/mongodb:/data -d reiz/mongodb:3.2.0
Mounts “/mnt/mongodb” directory into the Docker container as “/data”.
Keep the data on the host. That’s how you keep data persisted.
32. Set environment variables
> docker run --envLANG=en_US.UTF-8 -d reiz/mongodb:3.2.0
You can overwrite ENV variables from the Dockerfile here and also define
completely new ones.
61. Simple Playbook
---
- hosts: dev_servers
user: ubuntu
sudo: true
roles:
- java
- memcached
- hosts: www_servers
user: ubuntu
sudo: true
roles:
- java
group name from the inventory file
server auth
Role which should be installed on the server
70. Handlers
---
- name: restart mongodb
service: name=mongod state=restarted
mongo/handlers/main.yml
- name: copy MongoDB configuration to the server
copy: src=mongodb.conf dest=/etc/mongodb.conf
notify: restart mongodb
mongo/tasks/main.yml
71. Files
mongo/files/mongodb.list
- name: add MongoDB debian server to the list of servers
copy: src=mongodb.list dest=/etc/apt/sources.list.d/mongodb.list
mongo/tasks/main.yml