Based on Linux Containers! • Linux Containers can be difficult to set up • Extra Docker tooling looked fantastic That looks really cool DevOps Consultancy
we can just deploy Docker images? • I went through the getting started guide; wow this is all very clever • Got as far as the Dockerfile That looks really cool DevOps Consultancy
Victor Vieux <[email protected]> ! RUN apt-get update && apt-get install -y inotify-tools nginx apache2 openssh-server Dockerfile Hang on, that’s basically a bash script!
Chef cookbooks rather than with Dockerfile/bash • Idempotently manage the running state of your docker container • Manage multiple services (i.e. have more than one process running) DevOps Consultancy
management for development, staging and production • Use Docker containers for development of multi-tiered SOA applications but still deploy to bare metal or cloud instances in production Why use with ? DevOps Consultancy
gives it the ability to initialise and build Linux containers http://docs.getchef.com/plugin_knife_container.html • Chef Container Solves the Docker PID1 problem by running chef-client on boot and managing multiple processes with runit https://docs.getchef.com/containers.html DevOps Consultancy
the problem of repeatably creating machines and infrastructures in Chef https://github.com/opscode/chef-metal • Docker cookbook Chef cookbook which installs Docker https://supermarket.getchef.com/cookbooks/docker DevOps Consultancy
Chef DK $ gem install knife-container Install via RubyGems $ /opt/chef/embedded/bin/gem install knife-container RubyGems if Chef was installed via Omnibus Installer DevOps Consultancy
-r 'recipe[apache2]' -z -b -f chef/ubuntu_14.04 Used to set up a Dockerfile context for the local workstation Example: Creates a Dockerfile like: FROM chef/ubuntu_14.04 ADD chef /etc/chef RUN chef-init --bootstrap ENTRYPOINT ["chef-init"] CMD ["--onboot"] DevOps Consultancy
configuration • Protects your container from configuration drift • Use same set up for production, staging, Vagrant/CI and CD Why run Chef in your container? DevOps Consultancy
Chef DK $ gem install chef-metal Install via RubyGems $ /opt/chef/embedded/bin/gem install chef-metal RubyGems if Chef was installed via Omnibus Installer chef_gem 'chef-metal' do action :install end Or in a Chef recipe DevOps Consultancy
can have different drivers • Just run chef-client on the machine looking after the cluster rather than on each machine • That’s good if you don’t want chef-client running all the time in each your container DevOps Consultancy
with the Chef DK $ gem install chef-metal-docker Install via RubyGems $ /opt/chef/embedded/bin/gem install chef-metal-docker RubyGems if Chef was installed via Omnibus Installer chef_gem ‘chef-metal-docker' do action :install end Or in a Chef recipe DevOps Consultancy
Run container exposing ports docker_container 'samalba/docker-registry' do detach true port '5000:5000' env 'SETTINGS_FLAVOR=local' volume '/mnt/docker:/docker-storage' end ! # Login to private registry docker_registry 'https://docker-registry.example.com/' do username 'shipper' password 'iloveshipping' end ! # Pull tagged image docker_image 'apps/crowsnest' do tag 'not-latest' end Example LWRPs DevOps Consultancy
current timestamp timestamp = Time.new.strftime('%Y%m%d%H%M') ! # Commit container changes docker_container 'crowsnest' do repository 'apps' tag timestamp action :commit end ! # Push image docker_image 'crowsnest' do repository 'apps' tag timestamp action :push end Example LWRPs DevOps Consultancy
work for GDS and now works for Puppet http://www.devopsweekly.com/ • Puppet module with similar functionality • https://forge.puppetlabs.com/garethr/docker DevOps Consultancy