Docker: Build, Ship, and Run


The Presentation inside:

Slide 0

Docker Build, Ship and Run GDG Spaghetti Code Liberec, 6.10.2015 1


Slide 1

Ladislav Prskavec 4 Twitter: @abtris 4 Blog: http://blog.prskavec.net 4 Site Reliability Engineer (SRE) in Apiary.io GDG Spaghetti Code Liberec, 6.10.2015 2


Slide 2

GDG Spaghetti Code Liberec, 6.10.2015 3


Slide 3

What's Docker? GDG Spaghetti Code Liberec, 6.10.2015 4


Slide 4

Analogy from logistics GDG Spaghetti Code Liberec, 6.10.2015 5


Slide 5

Goods, wares GDG Spaghetti Code Liberec, 6.10.2015 6


Slide 6

Containers GDG Spaghetti Code Liberec, 6.10.2015 7


Slide 7

Why Docker? GDG Spaghetti Code Liberec, 6.10.2015 8


Slide 8

Fast and scalable GDG Spaghetti Code Liberec, 6.10.2015 9


Slide 9

Build once, run anywhere GDG Spaghetti Code Liberec, 6.10.2015 10


Slide 10

Configure once, run anywhere GDG Spaghetti Code Liberec, 6.10.2015 11


Slide 11

Example of using Docker 4 build documentation in Sphinx with latex support 4 executing code in many different programming languages without requiring a single compiler or script interpreter on your machine - docker exec 4 running gui app in docker at linux GDG Spaghetti Code Liberec, 6.10.2015 12


Slide 12

Example of using Docker 4 development without install ing many tools at local machine 4 Vagrant, Otto dev 4 continues integration using docker 4 Jenkins, TravisCI, CircleCI 4 DevOps platform for build, deploy and manage apps across any cloud - Tutum GDG Spaghetti Code Liberec, 6.10.2015 13


Slide 13

Docker Engine GDG Spaghetti Code Liberec, 6.10.2015 14


Slide 14

Docker Engine GDG Spaghetti Code Liberec, 6.10.2015 15


Slide 15

VM vs Docker GDG Spaghetti Code Liberec, 6.10.2015 16


Slide 16

Containers and images docker run hello-world GDG Spaghetti Code Liberec, 6.10.2015 17


Slide 17

Docker Remote API 4 client & server in Docker 4 docker ps 4 docker build 4 docker push/pull 4 docker run/stop 4 docker inspect GDG Spaghetti Code Liberec, 6.10.2015 18


Slide 18

Docker lifecycle 4 a build produces an immutable image 4 a container is as instance of the image GDG Spaghetti Code Liberec, 6.10.2015 19


Slide 19

Docker lifecycle GDG Spaghetti Code Liberec, 6.10.2015 20


Slide 20

Container lifecycle GDG Spaghetti Code Liberec, 6.10.2015 21


Slide 21

Dockerfile # Firefox over VNC # # VERSION 0.3 FROM ubuntu # Install vnc, xvfb in order to create a 'fake' display and firefox RUN apt-get update && apt-get install -y x11vnc xvfb firefox RUN mkdir ~/.vnc # Setup a password RUN x11vnc -storepasswd 1234 ~/.vnc/passwd # Autostart firefox (might not be the best way, but it does the trick) RUN bash -c 'echo "firefox" >> /.bashrc' EXPOSE 5900 CMD ["x11vnc", "-forever", "-usepw", "-create"] GDG Spaghetti Code Liberec, 6.10.2015 22


Slide 22

DockerHub GDG Spaghetti Code Liberec, 6.10.2015 23


Slide 23

GDG Spaghetti Code Liberec, 6.10.2015 24


Slide 24

Docker tools GDG Spaghetti Code Liberec, 6.10.2015 25


Slide 25

Docker compose 4 defining and running multi-container applications with Docker GDG Spaghetti Code Liberec, 6.10.2015 26


Slide 26

docker-compose.yml web: build: . ports: - "5000:5000" volumes: - .:/code links: - redis redis: image: redis GDG Spaghetti Code Liberec, 6.10.2015 27


Slide 27

Docker machine 4 Machine lets you create Docker hosts on your computer, on cloud providers, and inside your own data center. 4 part of Docker toolbox 4 replacement for boot2docker GDG Spaghetti Code Liberec, 6.10.2015 28


Slide 28

Demo GDG Spaghetti Code Liberec, 6.10.2015 29


Slide 29

Docker swarm 4 Docker Swarm is native clustering for Docker. GDG Spaghetti Code Liberec, 6.10.2015 30


Slide 30

Kinematic 4 desktop GUI for Docker 4 Mac and Windows only GDG Spaghetti Code Liberec, 6.10.2015 31


Slide 31

Docker Trusted Registry (DTR) 4 private dedicated image registry GDG Spaghetti Code Liberec, 6.10.2015 32


Slide 32

Yours private registry 4 storage at S3 docker run \ -d \ -p 5000:5000 \ --restart=always \ --name registry \ registry:2 GDG Spaghetti Code Liberec, 6.10.2015 33


Slide 33

Open Container 1 ekosystem https://www.mindmeister.com/389671722/open-container-ecosystemformerly-docker-ecosystem 1 GDG Spaghetti Code Liberec, 6.10.2015 34


Slide 34

GDG Spaghetti Code Liberec, 6.10.2015 35


Slide 35

Docker at Heroku heroku plugins:install heroku-docker 4 https://gist.github.com/abtris/ 6aca9b2668b8b5af0208 4 app.json must contain: { image: heroku/nodejs } 4 app.json specification GDG Spaghetti Code Liberec, 6.10.2015 36


Slide 36

Dockerfile - heroku/nodejs # Inherit from Heroku's stack FROM heroku/cedar:14 # Internally, we arbitrarily use port 3000 ENV PORT 3000 # Which version of node? ENV NODE_ENGINE 0.12.2 # Locate our binaries ENV PATH /app/heroku/node/bin/:/app/user/node_modules/.bin:$PATH # Create some needed directories RUN mkdir -p /app/heroku/node /app/.profile.d WORKDIR /app/user # Install node RUN curl -s https://s3pository.heroku.com/node/v$NODE_ENGINE/node-v$NODE_ENGINE-linux-x64.tar.gz | \ tar --strip-components=1 -xz -C /app/heroku/node # Export the node path in .profile.d RUN echo "export PATH=\"/app/heroku/node/bin:/app/user/node_modules/.bin:\$PATH\"" > \ /app/.profile.d/nodejs.sh ONBUILD ADD package.json /app/user/ ONBUILD RUN /app/heroku/node/bin/npm install ONBUILD ADD . /app/user/ GDG Spaghetti Code Liberec, 6.10.2015 37


Slide 37

Create Dockerfile heroku docker:init $ cat Dockerfile FROM heroku/nodejs GDG Spaghetti Code Liberec, 6.10.2015 38


Slide 38

Docker compose web: build: . command: 'bash -c ''node index.js''' working_dir: /app/user environment: PORT: 8080 ports: - '8080:8080' shell: build: . command: bash working_dir: /app/user environment: PORT: 8080 ports: - '8080:8080' volumes: - '.:/app/user' GDG Spaghetti Code Liberec, 6.10.2015 39


Slide 39

Start development environment $ docker-compose up web Building web... ... $ curl "http://$(docker-machine ip dev):8080" GDG Spaghetti Code Liberec, 6.10.2015 40


Slide 40

Rebuild containers Changes to your app and config. docker-compose build GDG Spaghetti Code Liberec, 6.10.2015 41


Slide 41

Heroku Release $ heroku create ... $ heroku docker:release ... $ heroku open GDG Spaghetti Code Liberec, 6.10.2015 42


Slide 42

Demo GDG Spaghetti Code Liberec, 6.10.2015 43


Slide 43

AWS Release $ docker build -t abtris/docker-liberec-example-app ... $ docker push abtris/docker-liberec-example-app ... $ docker pull abtris/docker-liberec-example-app ... GDG Spaghetti Code Liberec, 6.10.2015 44


Slide 44

Run on AWS $ docker run \ -d \ -p 3000:3000 \ abtris/docker-liberec-example-app \ node index.js $ curl http://localhost:3000 GDG Spaghetti Code Liberec, 6.10.2015 45


Slide 45

Demo GDG Spaghetti Code Liberec, 6.10.2015 46


Slide 46

Docker & AWS 4 Elastic Beanstalk 4 EC2 Container Service (ECS) 4 EC2 with Swarm, Mesos or Kubernetes GDG Spaghetti Code Liberec, 6.10.2015 47


Slide 47

Questions? GDG Spaghetti Code Liberec, 6.10.2015 48


Slide 48

Credits 4 boat-containers.jpg 2 4 computer-scrap.jpg [^3] 4 vm-vs-docker.png [^4] 4 docker logos [^5] 4 formule_one.jpg [^6] https://www.flickr.com/photos/[email protected]/3451530961/ [^3]: https://www.flickr.com/photos/[email protected]/2019666131/ [^4]: http://www.jayway.com/wp-content/uploads/2015/03/vm-vs-docker.png [^5]: https://www.docker.com/brand-guidelines 2 GDG Spaghetti Code Liberec, 6.10.2015 49


Slide 49


×

HTML:





Ссылка: