Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Docker - Build, Ship and Run

Docker - Build, Ship and Run

GDGSCL - Docker a jeho provoz v Heroku a AWS

- Example app - https://gist.github.com/abtris/6aca9b2668b8b5af0208
- Video (in czech) - https://www.youtube.com/watch?v=p6olO6NChno&feature=youtu.be

Ladislav Prskavec

October 06, 2015
Tweet

More Decks by Ladislav Prskavec

Other Decks in Technology

Transcript

  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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. docker-compose.yml web: build: . ports: - "5000:5000" volumes: - .:/code

    links: - redis redis: image: redis GDG Spaghetti Code Liberec, 6.10.2015 27
  8. 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
  9. Docker swarm 4 Docker Swarm is native clustering for Docker.

    GDG Spaghetti Code Liberec, 6.10.2015 30
  10. Kinematic 4 desktop GUI for Docker 4 Mac and Windows

    only GDG Spaghetti Code Liberec, 6.10.2015 31
  11. 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
  12. 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
  13. 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
  14. 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
  15. Start development environment $ docker-compose up web Building web... ...

    $ curl "http://$(docker-machine ip dev):8080" GDG Spaghetti Code Liberec, 6.10.2015 40
  16. Heroku Release $ heroku create ... $ heroku docker:release ...

    $ heroku open GDG Spaghetti Code Liberec, 6.10.2015 42
  17. 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
  18. 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
  19. 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
  20. 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] 2 https://www.flickr.com/photos/41864721@N00/3451530961/ [^3]: https://www.flickr.com/photos/7362086@N02/2019666131/ [^4]: http://www.jayway.com/wp-content/uploads/2015/03/vm-vs-docker.png [^5]: https://www.docker.com/brand-guidelines GDG Spaghetti Code Liberec, 6.10.2015 49