Skip to content

Instantly share code, notes, and snippets.

@mickelsonm
Last active January 19, 2016 03:48
Show Gist options
  • Save mickelsonm/a61efa6d925a36543cfa to your computer and use it in GitHub Desktop.
Save mickelsonm/a61efa6d925a36543cfa to your computer and use it in GitHub Desktop.
Docker for the Working Technologist Presentation

Docker for the Working Technologist

Container technologies, like Docker, are making their appearance in many technology shops across the globe. Come see some of my use cases for it and how “Dockerizing” things can be both fun and challenging. I am hoping that as a working technologist, you will find some use cases of your own and at the very least, it should provoke thought into how you are currently developing your tools or services within your own technology stacks.

Presentation given 11/16/2015

What's Docker?

https://www.docker.com/what-docker

How do I get Docker?

  • Install with Home Brew / Home Brew Cask
  • Install with the Docker Toolbox

What's in the Docker toolbox?

  • docker engine (daemon)
  • docker-machine
  • docker-compose
  • docker kitematic
  • VirtualBox

Demos

Interacting with docker-machine

Creating a new docker machine:

docker-machine create -d virtualbox demo

Setting the active docker machine:

eval "$(docker-machine env demo)"

Verify that we have things setup for us:

docker-machine ls #shows that we have the demo machine created/running

docker version #verifies that we have docker working for us

Interacting with the docker engine

Let's go out and get wordpress:

docker pull tutum/wordpress

Let's spin up our own wordpress instance:

docker run -d -p 1337:80 tutum/wordpress

Note: If you don't have the image locally...no worries, it'll pull it down for us automagically before it goes to run it.

Navigate to that instance in the browser:

open http://$(docker-machine ip demo):1337

Show docker-compose

GoTodo Application - Just a toy application we want to "Dockerize".

Using the docker-compose.yml file we can simply run this to bring everything online:

docker-compose up -d

When we are done, we can run the following items:

docker-compose stop

docker-compose rm

Note: You can supply the -f flag on rm to not be prompted.

Docker Compose does a lot of the heavy lifting for us...linking the containers together, managing environment variables, using specific commands, etc. Your use case will vary, but you will see the power of it the more you use it.

Using docker in production

  • Jenkins builds docker images, then puts them in docker registry. Some of my apps I do have a full deploy setup, meaning it connects to the target machine via ssh, then runs the associated docker commands on that target (docker pull, docker run, etc).
  • Respective system can just docker pull mylocalrepo/myapp, then docker run it to have it ready to go
  • Authorized users can also pull these images locally from the private repository

Scaling your application out on Google Compute Engine (GCE), AWS Elastic Container Service (ECS)

Once you have a docker image...you can interact with container engines/schedulers which will do different things for you. For example, auto-scaling your application or setting up infrastructure/platform type things are two basic examples. Notice the docker image piece plugs into how the manifest/task files are setup, so it proves that once you have Docker down...you evolve into bigger things quickly.

Conclusion / Questions

  • Feel free to ask me on Twitter @mickelmr
  • Thank you!
{
"requiresAttributes": [],
"taskDefinitionArn": "arn:aws:ecs:us-west-2:xxxxxxxxxxxx:task-definition/myapi-backend:1",
"status": "INACTIVE",
"revision": 2,
"containerDefinitions": [
{
"volumesFrom": [],
"memory": 100,
"extraHosts": null,
"dnsServers": null,
"disableNetworking": null,
"dnsSearchDomains": null,
"portMappings": [
{
"hostPort": 3000,
"containerPort": 3000,
"protocol": "tcp"
}
],
"hostname": null,
"essential": true,
"entryPoint": [],
"mountPoints": [],
"name": "myapi",
"ulimits": null,
"dockerSecurityOptions": null,
"environment": [
{
"name": "NODE_ENV",
"value": "production"
}
],
"links": [],
"workingDirectory": null,
"readonlyRootFilesystem": null,
"image": "my-private-repo.website.com/myapi",
"command": [],
"user": null,
"dockerLabels": null,
"logConfiguration": null,
"cpu": 10,
"privileged": null
}
],
"volumes": [],
"family": "myapi-backend",
"statusString": "(INACTIVE)"
}
version: v1
kind: Pod
metadata:
name: myapi
spec:
containers:
- name: redis
image: redis
imagePullPolicy: IfNotPresent
command: ["redis-server", "--requirepass", "supersecret", "--masterauth", "supersecret", "--slaveof", "123.123.123.123", "6379"]
ports:
- name: redis-access
hostPort: 6379
containerPort: 6379
protocol: TCP
- name: myapi
image: gcr.io/myproject/myapi
imagePullPolicy: Always
ports:
- name: http
hostPort: 80
containerPort: 9090
protocol: TCP
env:
- name: REDIS_CLIENT_ADDRESS
value: 172.17.42.1
- name: REDIS_MASTER_ADDRESS
value: 123.123.123.123
- name: REDIS_SECRET
value: supersecret
restartPolicy: OnFailure
@mickelsonm
Copy link
Author

Here's a flowchart I made for this presentation, but I never used:

flowchart

It reads from bottom to top.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment