A presentation at NewHavenIO - Containers/Kubernetes Talks in in New Haven, CT, USA by Henry Quinn
HENRY QUINN INTRO TO DOCKER
ABOUT ME ▸ NewHaven.IO ▸ Member Board of Directors ▸ U.S. District Court, District of Connecticut ▸ Programmer, Analyst, Database Administrator ▸ Administrative Office of the US Courts ▸ Software Developer - Temporary Duty Assignment
AGENDA PLAN FOR TODAY ▸ What I Was Tasked With ▸ What Was Expected Of Me ▸ VPS Overview (Virtual Private Server) ▸ What I Did Instead ▸ Docker Overview
WHAT I WAS TASKED WITH GET A COLDFUSION APP IN 16 COURTS IN UNDER A YEAR ▸ CONSTRAINTS ▸ Finish The Application ▸ Get It Cleared As Secure By IT Security Office ▸ Requisition Servers ▸ Install, Configure, And Test Applications
WHAT WAS EXPECTED OF ME AO CONTROLLED VIRTUAL PRIVATE SERVERS
WHAT WAS EXPECTED OF ME FROM NOTHING ▸ Contact AO To Allocate Space And Install CentOS ▸ Log In With SSH ▸ Change Root Password ▸ Set Up Fail2Ban ▸ Configure Firewall ▸ Install And Configure Java, Apache Tomcat, ColdFusion, MySQL ▸ Take Periodic Snapshots ▸ Git Clone My Repo ▸ Configure Separate Directories For Each Specific Judge ▸ Set Up A Custom Domain ▸ Fly To District To Spot Check Data And Train Administrators ▸ Final Hand Off
WHAT WAS EXPECTED OF ME PROBLEMS WITH THAT ▸ It takes a week. ▸ We don’t control other districts’ hardware. ▸ It takes even more work to set up failover solutions. ▸ Setting up directories of static code per judge doesn’t make sense. ▸ This all doesn’t leave very much time for future development efforts.
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD INFRASTRUCTURE AS CODE
WHAT I DID INSTEAD BROAD OVERVIEW ▸ Docker is a container management engine. ▸ Containers are builds that run the same on every platform. ▸ Containers are built from images, kind of like an .ISO file. ▸ Images are built using Dockerfiles. ▸ Dockerfiles are just text files with lists of instructions on how to build, configure, and run your environments.
WHAT I DID INSTEAD DOCKERFILES (PSEUDOCODE) FROM lucee/lucee5:5.0.1.85 COPY config/lucee/setenv.sh /usr/local/tomcat/bin/ COPY config/lucee/lucee-web.xml.cfm /opt/lucee/web/ COPY config/lucee/lucee-server.xml /opt/lucee/server/ lucee-server/context/ ENV ELI_DSN_DRIVER=MySQL \ ELI_DSN_CLASS=org.gjt.mm.mysql.Driver \ … COPY code/ /var/www/
WHAT I DID INSTEAD IMAGES ▸ An image is an inert, immutable file that’s essentially a snapshot of a container. ▸ Images are created from Dockerfiles, which are made of instructions that build layers on top of a metaphorical system. ▸ Running “build” on a Dockerfile creates an image, while running “run” on an image spawns an instance of that image. ▸ A running instance of an image is called a container, of which you can have multiple based on the same image.
WHAT I DID INSTEAD CONTAINERS
WHAT I DID INSTEAD BUILDING AN IMAGE ▸ $ docker build —rm -t quinncuatro/eli-lucee . ▸ Boring Nerd Stuff ————>
WHAT I DID INSTEAD USING AN IMAGE TO MAKE A CONTAINER ▸ $ docker images | grep eli-lucee ▸ $ docker run -d -p 127.0.0.1:8888:8888 —restart always -name eli-lucee —mount type=bind,source=$(pwd)/ code,target=/var/www quinncuatro/eli-lucee:latest ▸
WHAT I DID INSTEAD VERIFYING THAT THE CONTAINER IS RUNNING ▸ $ docker ps -a | grep eli-lucee
WHAT I DID INSTEAD PROBLEMS WITH THAT ▸ It’s only one container. ▸ It’s not connected to a database. ▸ How would we even persist the database container’s data? ▸ If we set a database container up, how do we make the containers talk?
WHAT I DID INSTEAD DOCKER COMPOSE YAML version: “3.5” services: lucee-eli: build: context: ./lucee dockerfile: Dockerfile container_name: eli-lucee ports: - “8888:8888” networks: - eli-net db-eli: build: context: ./mysql dockerfile: Dockerfile container_name: eli-db volumes: - eli_dbdata:/var/lib/mysql networks: - eli-net volumes: eli_dbdata: networks: eli-net: driver: bridge
WHAT I DID INSTEAD CREATING MULTIPLE CONTAINERS WITH DOCKER-COMPOSE ▸ $ docker-compose up -d ▸ $ docker ps -a
WHAT I DID INSTEAD VERIFYING THAT THE CONTAINERS ARE RUNNING
WHAT I DID INSTEAD NOW LETS ITERATE EVEN FASTER ▸ In spinup.sh (a bash script that executes different sets of Docker commands for me) there’s a line: ▸ $ docker run -d -p 127.0.0.1:8888:8888 —restart always — name eli-lucee —mount type=bind,source=$(pwd)/lucee/ code,target=/var/www —network eli-net devc_luceeeli:latest ▸ —mount type=bind,source=$(pwd)/lucee/code,target=/ var/www
WHAT I DID INSTEAD PLATFORM AGNOSTIC ▸ Docker can generate containers that run the same no matter where they are, whether it be: ▸ Windows 10/Server ▸ OS X >= 10.11 (El Cap) ▸ CentOS, Debian, Fedora, RHEL, SUSE, Ubuntu ▸ AWS ▸ Azure ▸ GCE
WHAT I DID INSTEAD PLATFORM AGNOSTIC ▸ Now, why is that a benefit? ▸ You can spin your apps and data layers up REALLY fast. ▸ No hand configs when trying out new tools, just “$ docker run ${whatever}” and go. ▸ Develop and deploy with the exact same point releases of operating systems and dependencies. ▸ Ensures that your applications are isolated and segregated. ▸ Use the same image through the entire CI process.
WIND DOWN PLAN FOR TODAY ▸ What I Was Tasked With ▸ What Was Expected Of Me ▸ VPS Overview (Virtual Private Server) ▸ What I Did Instead ▸ Docker Overview
RESOURCES HELPFUL LINKS (DIGITAL OCEAN) ▸ Digital Ocean Referral Code (Free $10 Credit) ▸ https://m.do.co/c/c4539d6703fe ▸ Digital Ocean CentOS Guides ▸ https://www.digitalocean.com/community/tutorials/ initial-server-setup-with-centos-7 ▸ https://www.digitalocean.com/community/tutorials/howto-install-linux-apache-mysql-php-lamp-stack-on-centos-7
RESOURCES HELPFUL LINKS (DOCKER) ▸ Install Docker CE (Community Edition) ▸ https://docs.docker.com/engine/installation/ ▸ Getting Started ▸ Mac - https://docs.docker.com/docker-for-mac/ ▸ PC - https://docs.docker.com/docker-for-windows/ ▸ Docker Labs - https://github.com/docker/labs
Containers are starting to become more and more of a buzzword in our industry. As the first talk of the night, I’ll help get everyone up to speed on what containers are, how Docker can help you succeed, and run a demo on Docker-Compose.
After I’m done, I’ll hand off the baton to another speaker to let y’all know about Kubernetes, a popular container orchestration platform.
https://www.meetup.com/newhavenio/events/259374344/