Successfully reported this slideshow.
Your SlideShare is downloading. ×

Docker: From Zero to Hero

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Introduction to docker
Introduction to docker
Loading in …3
×

Check these out next

1 of 12 Ad

More Related Content

Slideshows for you (20)

Viewers also liked (17)

Advertisement

Similar to Docker: From Zero to Hero (20)

More from Espeo Software (20)

Advertisement

Recently uploaded (20)

Docker: From Zero to Hero

  1. 1. INTRODUCTION
  2. 2. INTRODUCTION PROMISES ▸ isolation ▸ lightness ▸ repeatability ▸ speed ▸ easy collaboration ▸ easy configuration
  3. 3. INTRODUCTION WHY DOCKER?
  4. 4. INTRODUCTION TECHNOLOGIES ▸ LXC - Linux Containers - process isolation ▸ UnionFS - layered file system ▸ Go - programming language LINUX UNION FS LXC DOCKER (GO)
  5. 5. ▸ container - run ▸ image - build ▸ registry - pull/push INTRODUCTION TERMS AND OPERATIONS
  6. 6. EXAMPLE MINECRAFT SERVER # Minecraft 1.8.7 Dockerfile - Example with notes # Use the offical Debian Docker image with a specified version tag, Wheezy, so not all # versions of Debian images are downloaded. FROM debian:wheezy # Use APT (Advanced Packaging Tool) built in the Linux distro to download Java, a dependency to run Minecraft. RUN apt-get -y update RUN apt-get -y install openjdk-7-jre-headless wget # Download Minecraft Server components RUN wget -q https://s3.amazonaws.com/Minecraft.Download/versions/1.9.2/ minecraft_server.1.9.2.jar # Sets working directory for the CMD instruction (also works for RUN, ENTRYPOINT commands) # Create mount point, and mark it as holding externally mounted volume WORKDIR /data VOLUME /data # Expose the container's network port: 25565 during runtime. EXPOSE 25565 #Automatically accept Minecraft EULA, and start Minecraft server CMD echo eula=true > /data/eula.txt && java -jar /minecraft_server.1.9.2.jar
  7. 7. DEMO JUMP AT THE DEEP END
  8. 8. DEMO WHAT’S THE GOAL ▸ bpasik’s Node.js app with Mongo DB running on Docker
 https://github.com/Gustu/Node-Asynchronous-Examples TOOLS REFERENCE ▸ Docker hub
 https://hub.docker.com/_/node
 https://hub.docker.com/_/mongo/ ▸ Dockerfile
 https://docs.docker.com/engine/reference/builder/ ▸ Docker compose
 https://docs.docker.com/compose/

  9. 9. DEMO BUILD IT # Dockerfile FROM node:onbuild EXPOSE 3000 RUN IT # run mongo as daemon container and expose it’s 27017 port to localhost’s 27017 # WARNING: on Windows or OS X Docker is not running on localhost # it’s running on boot2docker VM with it’s own IP # so it’s exposing this port as e.g. 192.169.99.100:27017 # (this also means you’d have to embed this IP into config/default.json) $ docker run -d -p 27017:27017 mongo << mongo container id here>> # build our app Docker image and tag it as node-app $ docker build -t node-app . << lots of logs here >> # run mongo as daemon and expose container’s port 3000 to localhost’s 3000 $ docker run -d -p 3000:3000 node-app << node-app container id here>> # you can now access localhost:3000 and see the running containers $ docker ps
  10. 10. DEMO BUT RUNNING IT BY HAND EACH TIME IS UNCOOL… # WARNING: remove all containers (running and stopped) $ docker ps -qa | xargs docker rm -f Cleanup Declarative docker compose configuration # docker-compose.yml version: '2' services: web: # use our Dockerfile build: . # expose the port 3000 ports: - "3000:3000" links: # link the mongo container under hostname 'mongo' # remember to change config/default.json to use mongo:27017 - mongo mongo: image: mongo $ docker-compose up # try changing public/index.html and refresh the page Run it!
  11. 11. DEMO WHAT IF WE WANT TO EDIT LIVE FILES? $ docker-compose down Cleanup (the docker-compose way) Change our Dockerfile to use other base image # Dockerfile FROM node EXPOSE 3000 # point to our volume (where the app is mounted) WORKDIR /app # start with the app’s start command CMD [ "npm", "start" ] $ docker-compose up # try changing public/index.html again and see the changes live Run it! Change our docker-compose.yml to use a volume version: '2' services: web: build: . ports: - "3000:3000" # mount . directory to container’s /app volumes: - .:/app links: - mongo mongo: image: mongo
  12. 12. DEMO SUMMING UP ▸ we’ve started from running containers by hand ▸ defined Docker compose config with linked containers ▸ changed the app embedded in the image to be mounted as a volume ▸ Dockerization available in my fork of the app:
 https://github.com/tcichowicz/Node-Asynchronous- Examples

×