Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Basic docker for developer

1,647 views

Published on

Basic docker for developer training.

Prince of Songkla University, Phuket campus

Published in: Technology
  • Hello! Get Your Professional Job-Winning Resume Here - Check our website! https://vk.cc/818RFv
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Basic docker for developer

  1. 1. Docker For Developer
  2. 2. #whoami • Mr. Weerayut Hongsa (@kusumoto_ton) • Graduated from Prince of Songkla University, Phuket Campus Major Software Engineer • System Administrator / Infrastructure Engineer (Major Kantana Broadcasting Co., Ltd) • Software Developer (C#, Node.js, Lua, Java, PHP, Javascript) #Freelance • Software Developer (iCONEXT Co., Ltd) • Interesting DevOps, Software Development, Agile Methodology, CI/CD, Infrastructure As a Code
  3. 3. #resource https://github.com/Kusumoto/psu-docker-workshop-resource
  4. 4. What is Docker ? Mr.Weerayut Hongsa - @kusumoto_ton
  5. 5. Mr.Weerayut Hongsa - @kusumoto_ton
  6. 6. This is “Dock” :p Mr.Weerayut Hongsa - @kusumoto_ton
  7. 7. Mr.Weerayut Hongsa - @kusumoto_ton
  8. 8. Mr.Weerayut Hongsa - @kusumoto_ton
  9. 9. #docker?? “Software Container management platform” Mr.Weerayut Hongsa - @kusumoto_ton
  10. 10. #docker?? Mr.Weerayut Hongsa - @kusumoto_ton
  11. 11. What is Container ? Mr.Weerayut Hongsa - @kusumoto_ton
  12. 12. #container?? “Concept for create environment for software, without disturbing the rest of the core operating system.” Mr.Weerayut Hongsa - @kusumoto_ton
  13. 13. #container?? Mr.Weerayut Hongsa - @kusumoto_ton
  14. 14. Why to use Docker? Mr.Weerayut Hongsa - @kusumoto_ton
  15. 15. Ok, I have a new question. Do you have this problem? Mr.Weerayut Hongsa - @kusumoto_ton
  16. 16. Mr.Weerayut Hongsa - @kusumoto_ton
  17. 17. Mr.Weerayut Hongsa - @kusumoto_ton
  18. 18. Mr.Weerayut Hongsa - @kusumoto_ton
  19. 19. Mr.Weerayut Hongsa - @kusumoto_ton
  20. 20. FTP Mr.Weerayut Hongsa - @kusumoto_ton
  21. 21. FTP Mr.Weerayut Hongsa - @kusumoto_ton
  22. 22. FTP Mr.Weerayut Hongsa - @kusumoto_ton
  23. 23. FTP ? ? ? Mr.Weerayut Hongsa - @kusumoto_ton
  24. 24. FTP ? ? ? Software version is not been control. Mr.Weerayut Hongsa - @kusumoto_ton
  25. 25. I would say that, Docker can solve all problem. Mr.Weerayut Hongsa - @kusumoto_ton
  26. 26. #docker platform Docker Engine Docker Machine Docker Compose Docker Swarm Docker Registry Mr.Weerayut Hongsa - @kusumoto_ton
  27. 27. Why not use VM (Virtual Machine) ? Mr.Weerayut Hongsa - @kusumoto_ton
  28. 28. Virtual Machine (VM) Containers (Docker) #teamvm vs #teamcontainer Mr.Weerayut Hongsa - @kusumoto_ton
  29. 29. #docker solution Mr.Weerayut Hongsa - @kusumoto_ton
  30. 30. #docker edition • Community Edition (CE) • Enterprise Edition (EE) Mr.Weerayut Hongsa - @kusumoto_ton
  31. 31. Case Study (Development Case) PHP Web Application Development Mr.Weerayut Hongsa - @kusumoto_ton
  32. 32. PHP version requirement yii2 CodeIgniterPhalcon Symfony Laravel dokuwiki Wordpress Drupal 7 Drupal 8 Joomla Mr.Weerayut Hongsa - @kusumoto_ton
  33. 33. PHP version requirement yii2 (PHP 5.4+) CodeIgniter (PHP 5.6+)Phalcon (PHP 5.5+) Symfony (PHP 5.5.9+) Laravel (PHP 5.6.4+) dokuwiki (PHP 5.3.4+) Wordpress (PHP 5.2.4+) Drupal 7 (PHP 5.2.5+) Drupal 8 (PHP 5.5.9+) Joomla (PHP 5.3.10+) Mr.Weerayut Hongsa - @kusumoto_ton
  34. 34. PHP version requirement yii2 (PHP 5.4+) CodeIgniter (PHP 5.6+)Phalcon (PHP 5.5+) Symfony (PHP 5.5.9+) Laravel (PHP 5.6.4+) dokuwiki (PHP 5.3.4+) Wordpress (PHP 5.2.4+) Drupal 7 (PHP 5.2.5+) Drupal 8 (PHP 5.5.9+) Joomla (PHP 5.3.10+) Mr.Weerayut Hongsa - @kusumoto_ton
  35. 35. PHP Extension apxs2, mongo, db2, bcmath, bz2, calendar, cgi, cli, ctype, dab, debug, odbc, dom, embed, exif, fileinfo, filter, fpm, ftp, gcov, gd, gettext, hash, iconv, icu, imap, intl, ipc, ipv6, json, kerberos, mbregex, mbstring, mcrypt, mhash, mysql, openssl, pcntl, pcre, pdo, pgsql, phar, posix, readline, session, soap, sockets, sqlite, tidy, tokenize, xml_all, xmlrpc, zip, zlib Mr.Weerayut Hongsa - @kusumoto_ton
  36. 36. PHP Extension apxs2, mongo, db2, bcmath, bz2, calendar, cgi, cli, ctype, dab, debug, odbc, dom, embed, exif, fileinfo, filter, fpm, ftp, gcov, gd, gettext, hash, iconv, icu, imap, intl, ipc, ipv6, json, kerberos, mbregex, mbstring, mcrypt, mhash, mysql, openssl, pcntl, pcre, pdo, pgsql, phar, posix, readline, session, soap, sockets, sqlite, tidy, tokenize, xml_all, xmlrpc, zip, zlib Mr.Weerayut Hongsa - @kusumoto_ton
  37. 37. One Server Multiple Projects Server App 1 PHP MySQL Etc. App 2 PHP MariaDB Etc. App n PHP MySQL Etc. Mr.Weerayut Hongsa - @kusumoto_ton
  38. 38. One Server Multiple Projects Server App 1 PHP 5.2.1 MySQL 5.1 Etc. App 2 PHP 5.5.3 MariaDB 10 Etc. App n PHP 7.0 MySQL 5.6 Etc. Mr.Weerayut Hongsa - @kusumoto_ton
  39. 39. Mr.Weerayut Hongsa - @kusumoto_ton
  40. 40. Solve this problem! Mr.Weerayut Hongsa - @kusumoto_ton
  41. 41. Virtual Machine (VM) Mr.Weerayut Hongsa - @kusumoto_ton
  42. 42. Virtual Machine (VM) Can solve this problem Mr.Weerayut Hongsa - @kusumoto_ton
  43. 43. Virtual Machine (VM) Can solve this problem But not lightweight and use much more resources Mr.Weerayut Hongsa - @kusumoto_ton
  44. 44. PHPBrew Mr.Weerayut Hongsa - @kusumoto_ton
  45. 45. PHPBrew Almost good Mr.Weerayut Hongsa - @kusumoto_ton
  46. 46. PHPBrew Almost good But we need encapsulation, portability and portable Mr.Weerayut Hongsa - @kusumoto_ton
  47. 47. Vagrant Mr.Weerayut Hongsa - @kusumoto_ton
  48. 48. Vagrant That’s awesome! Mr.Weerayut Hongsa - @kusumoto_ton
  49. 49. Vagrant That’s awesome! But may it be more lightweight and portable Mr.Weerayut Hongsa - @kusumoto_ton
  50. 50. Docker Mr.Weerayut Hongsa - @kusumoto_ton
  51. 51. Docker That’s awesome! Lightweight, encapsulation, portability and portable Mr.Weerayut Hongsa - @kusumoto_ton
  52. 52. Can Docker help you? • Docker can create environment compatible for your software. • Docker separate disk space each project. • You software easy for implementation. • You software easy deployment and portability. Mr.Weerayut Hongsa - @kusumoto_ton
  53. 53. PHP Multi Version In One Server Mr.Weerayut Hongsa - @kusumoto_ton
  54. 54. Case Study (Operations Case) Large Scale Web Application Mr.Weerayut Hongsa - @kusumoto_ton
  55. 55. It's time to deployment Mr.Weerayut Hongsa - @kusumoto_ton
  56. 56. Basic Infrastructure Mr.Weerayut Hongsa - @kusumoto_ton
  57. 57. Basic Infrastructure Mr.Weerayut Hongsa - @kusumoto_ton
  58. 58. Basic Infrastructure Mr.Weerayut Hongsa - @kusumoto_ton
  59. 59. Cloud Infrastructure Block Storage Cluster Farm Mr.Weerayut Hongsa - @kusumoto_ton
  60. 60. Cloud Infrastructure Block Storage Cluster Farm Mr.Weerayut Hongsa - @kusumoto_ton
  61. 61. Cloud Infrastructure Block Storage Cluster Farm Mr.Weerayut Hongsa - @kusumoto_ton
  62. 62. Cloud Infrastructure Block Storage Cluster Farm Mr.Weerayut Hongsa - @kusumoto_ton
  63. 63. Who’s using #docker? Mr.Weerayut Hongsa - @kusumoto_ton
  64. 64. How do you know software support #docker? Mr.Weerayut Hongsa - @kusumoto_ton
  65. 65. How do you know software support #docker? Mr.Weerayut Hongsa - @kusumoto_ton
  66. 66. We talk about an element of Docker. Mr.Weerayut Hongsa - @kusumoto_ton
  67. 67. Element of Docker Registry (Docker Repository)ContainerImage Mr.Weerayut Hongsa - @kusumoto_ton
  68. 68. Image ”A template of container” Mr.Weerayut Hongsa - @kusumoto_ton
  69. 69. Image • Linux or Windows Inside. • Already install the application and environment. • Build from Dockerfile or container. • After build image, the image can been read only. • Template of container. Mr.Weerayut Hongsa - @kusumoto_ton
  70. 70. Container ”Wrap up a piece of software in a complete filesystem that contains everything it needs to run” Mr.Weerayut Hongsa - @kusumoto_ton
  71. 71. Container • Create from image. • Running Process • Can modify/access after container up and running • Commit change to create image Mr.Weerayut Hongsa - @kusumoto_ton
  72. 72. Registry ”The repository of images” Mr.Weerayut Hongsa - @kusumoto_ton
  73. 73. Registry • Contain a lot of images. • There are many services, Docker hub is key future. • Image on registry can pull from any location. Mr.Weerayut Hongsa - @kusumoto_ton
  74. 74. Image vs Container • Compare the OOP concept (Image = Class, Container = Object) • Image can't writable / Container can writeable • Image can extends • Image need transform to Container only for runnable. Mr.Weerayut Hongsa - @kusumoto_ton
  75. 75. Next step, we talk about Docker workflow. Mr.Weerayut Hongsa - @kusumoto_ton
  76. 76. #docker workflow Mr.Weerayut Hongsa - @kusumoto_ton
  77. 77. #docker workflow Image (from registry) Mr.Weerayut Hongsa - @kusumoto_ton
  78. 78. #docker workflow Image (from registry) Image (from local) PULL Mr.Weerayut Hongsa - @kusumoto_ton
  79. 79. #docker workflow Image (from registry) Image (from local) Container PULL RUN Mr.Weerayut Hongsa - @kusumoto_ton
  80. 80. #docker workflow Image (from registry) Image (from local) Container Container (changed) PULL RUN CHANGE Mr.Weerayut Hongsa - @kusumoto_ton
  81. 81. #docker workflow Image (from registry) Image (from local) Container Container (changed) PULL RUN CHANGE COMMIT Mr.Weerayut Hongsa - @kusumoto_ton
  82. 82. #docker workflow Image (from registry) Image (from local) Container Container (changed) PULL RUN CHANGE COMMIT PUSH Mr.Weerayut Hongsa - @kusumoto_ton
  83. 83. #docker workflow Image (from registry) Image (from local) Container Container (changed) PULL RUN CHANGE COMMIT PUSH Mr.Weerayut Hongsa - @kusumoto_ton
  84. 84. #docker workflow Dockerfile Mr.Weerayut Hongsa - @kusumoto_ton
  85. 85. #docker workflow Image (from local)Dockerfile BUILD Mr.Weerayut Hongsa - @kusumoto_ton
  86. 86. #docker workflow Image (from local)Dockerfile Image (from registry) PUSH BUILD Mr.Weerayut Hongsa - @kusumoto_ton
  87. 87. #docker workflow Image (from local)Dockerfile BUILD Image (from registry) PUSH PULL Mr.Weerayut Hongsa - @kusumoto_ton
  88. 88. #docker workflow Image (from local)Dockerfile BUILD Image (from registry) PUSH PULL Container RUN Mr.Weerayut Hongsa - @kusumoto_ton
  89. 89. #docker workflow Image (from local)Dockerfile BUILD Image (from registry) PUSH PULL Container RUN Mr.Weerayut Hongsa - @kusumoto_ton
  90. 90. Go back to #docker solution. Mr.Weerayut Hongsa - @kusumoto_ton
  91. 91. #docker solution Mr.Weerayut Hongsa - @kusumoto_ton
  92. 92. #docker solution Image (from registry) Image (from local) Container Container (changed) PULL RUN CHANGE COMMIT PUSH Build Mr.Weerayut Hongsa - @kusumoto_ton
  93. 93. #docker solution Image (from registry) Image (from local) Container Container (changed) PULL RUN CHANGE COMMIT PUSH Ship Mr.Weerayut Hongsa - @kusumoto_ton
  94. 94. #docker solution Image (from registry) Image (from local) Container Container (changed) PULL RUN CHANGE COMMIT PUSH Run Mr.Weerayut Hongsa - @kusumoto_ton
  95. 95. #docker solution Image (from local)Dockerfile BUILD Image (from registry) PUSH PULL Container RUN Build Mr.Weerayut Hongsa - @kusumoto_ton
  96. 96. #docker solution Image (from local)Dockerfile BUILD Image (from registry) PUSH PULL Container RUN Ship Mr.Weerayut Hongsa - @kusumoto_ton
  97. 97. #docker solution Image (from local)Dockerfile BUILD Image (from registry) PUSH PULL Container RUN Run Mr.Weerayut Hongsa - @kusumoto_ton
  98. 98. Do you understand #docker workflow and #docker solution? Mr.Weerayut Hongsa - @kusumoto_ton
  99. 99. Next step, we talk about #docker command Mr.Weerayut Hongsa - @kusumoto_ton
  100. 100. #docker workflow Image (from registry) Image (from local) Container Container (changed) PULL RUN CHANGE COMMIT PUSH Mr.Weerayut Hongsa - @kusumoto_ton
  101. 101. Pull image from repository to local docker pull ubuntu:xenial Mr.Weerayut Hongsa - @kusumoto_ton
  102. 102. Pull image from repository to local docker pull ubuntu:xenial Image Name Mr.Weerayut Hongsa - @kusumoto_ton
  103. 103. Pull image from repository to local docker pull ubuntu:xenial Mr.Weerayut Hongsa - @kusumoto_ton
  104. 104. #docker workflow Image (from registry) Image (from local) Container Container (changed) PULL RUN CHANGE COMMIT PUSH Mr.Weerayut Hongsa - @kusumoto_ton
  105. 105. Create container from image and run container docker run ubuntu:xenial /bin/echo “hello word” Mr.Weerayut Hongsa - @kusumoto_ton
  106. 106. docker run ubuntu:xenial /bin/echo “hello word” Image Name execute argument Create container from image and run container Mr.Weerayut Hongsa - @kusumoto_ton
  107. 107. docker run -d ubuntu:xenial /bin/echo “hello word” Image Name execute argument Create container from image and run container parameter Mr.Weerayut Hongsa - @kusumoto_ton
  108. 108. docker run ubuntu:xenial /bin/echo “hello word” Create container from image and run container Mr.Weerayut Hongsa - @kusumoto_ton
  109. 109. #docker workflow Image (from registry) Image (from local) Container Container (changed) PULL RUN CHANGE COMMIT PUSH Mr.Weerayut Hongsa - @kusumoto_ton
  110. 110. List container docker ps Mr.Weerayut Hongsa - @kusumoto_ton
  111. 111. List container docker ps Mr.Weerayut Hongsa - @kusumoto_ton
  112. 112. List container (include stopped) docker ps -a Mr.Weerayut Hongsa - @kusumoto_ton
  113. 113. List images docker images Mr.Weerayut Hongsa - @kusumoto_ton
  114. 114. List images docker images Mr.Weerayut Hongsa - @kusumoto_ton
  115. 115. Create a new image from a container’s changes docker commit d927d74ecd97 kusumoto/testhello:latest Image NameContainer Mr.Weerayut Hongsa - @kusumoto_ton
  116. 116. Create a new image from a container’s changes docker commit d927d74ecd97 kusumoto/testhello:latest Mr.Weerayut Hongsa - @kusumoto_ton
  117. 117. #docker workflow Image (from registry) Image (from local) Container Container (changed) PULL RUN CHANGE COMMIT PUSH Mr.Weerayut Hongsa - @kusumoto_ton
  118. 118. Push image docker push kusumoto/testhello:latest Mr.Weerayut Hongsa - @kusumoto_ton
  119. 119. Push image docker push kusumoto/testhello:latest Image Name (Match on repository) Mr.Weerayut Hongsa - @kusumoto_ton
  120. 120. Push image docker push kusumoto/testhello:latest Mr.Weerayut Hongsa - @kusumoto_ton
  121. 121. #docker workflow Image (from local)Dockerfile BUILD Image (from registry) PUSH PULL Container RUN Mr.Weerayut Hongsa - @kusumoto_ton
  122. 122. Build image from Dockerfile docker build -t kusumoto/tutu-bigo-tofblive . Mr.Weerayut Hongsa - @kusumoto_ton
  123. 123. Build image from Dockerfile docker build -t kusumoto/tutu-bigo-tofblive . Image Name Path Dockerfileparameter Mr.Weerayut Hongsa - @kusumoto_ton
  124. 124. Build image from Dockerfile docker build -t kusumoto/tutu-bigo-tofblive . Mr.Weerayut Hongsa - @kusumoto_ton
  125. 125. #docker workflow Image (from local)Dockerfile BUILD Image (from registry) PUSH PULL Container RUN Mr.Weerayut Hongsa - @kusumoto_ton
  126. 126. Push image docker push kusumoto/tutu-bigo-tofblive:latest Mr.Weerayut Hongsa - @kusumoto_ton
  127. 127. Push image docker push kusumoto/tutu-bigo-tofblive:latest Image Name (Match on repository) Mr.Weerayut Hongsa - @kusumoto_ton
  128. 128. Push image docker push kusumoto/tutu-bigo-tofblive:latest Mr.Weerayut Hongsa - @kusumoto_ton
  129. 129. #docker workflow Image (from local)Dockerfile BUILD Image (from registry) PUSH PULL Container RUN Mr.Weerayut Hongsa - @kusumoto_ton
  130. 130. docker run -d kusumoto/docker-openresty:latest Create container from image and run container -d : run container in background mode Mr.Weerayut Hongsa - @kusumoto_ton
  131. 131. docker run -d kusumoto/docker-openresty:latest Create container from image and run container Mr.Weerayut Hongsa - @kusumoto_ton
  132. 132. Utility Command Mr.Weerayut Hongsa - @kusumoto_ton
  133. 133. docker exec -it 158b4a099baf bash Execute shell into container Mr.Weerayut Hongsa - @kusumoto_ton
  134. 134. docker exec -it 158b4a099baf bash Execute shell into container Mr.Weerayut Hongsa - @kusumoto_ton
  135. 135. docker run -d -p 80:80 nginx:latest Image Name Create container and expose port to real host Run container background Expose port from container port 80 to local port 80 [local:container] Mr.Weerayut Hongsa - @kusumoto_ton
  136. 136. docker run -d -p 80:80 nginx:latest Create container and expose port to real host Mr.Weerayut Hongsa - @kusumoto_ton
  137. 137. docker run -d -v /home/kusumoto/test:/usr/share/nginx/html -p 80:80 nginx:latest Mapping host volume to container Mr.Weerayut Hongsa - @kusumoto_ton
  138. 138. docker run -d -v /home/kusumoto/test:/usr/share/nginx/html -p 80:80 nginx:latest Mapping host volume to container Run container background Expose port from container port 80 to local port 80 [local:container] Image Name Mapping volume to container [host:container] Mr.Weerayut Hongsa - @kusumoto_ton
  139. 139. docker run -d -v /home/kusumoto/test:/usr/share/nginx/html -p 80:80 nginx:latest Mapping host volume to container Mr.Weerayut Hongsa - @kusumoto_ton
  140. 140. docker system prune System cleanup Mr.Weerayut Hongsa - @kusumoto_ton
  141. 141. docker system prune System cleanup Mr.Weerayut Hongsa - @kusumoto_ton
  142. 142. docker login Registry Authentication Mr.Weerayut Hongsa - @kusumoto_ton
  143. 143. docker login Registry Authentication Mr.Weerayut Hongsa - @kusumoto_ton
  144. 144. Do you want to encapsulate your container? Mr.Weerayut Hongsa - @kusumoto_ton
  145. 145. Next step, we talk about #docker network Mr.Weerayut Hongsa - @kusumoto_ton
  146. 146. What is Docker Network? ”Control communicate between container” Mr.Weerayut Hongsa - @kusumoto_ton
  147. 147. Docker Network Mr.Weerayut Hongsa - @kusumoto_ton
  148. 148. Create new #docker network docker network create --driver bridge --subnet=192.168.1.0/24 --ip-range=192.168.1.128/25 --gateway=192.168.1.5 --opt="com.docker.network.mtu"="1500" backend Mr.Weerayut Hongsa - @kusumoto_ton
  149. 149. Create new #docker network docker network create --driver bridge --subnet=192.168.1.0/24 --ip-range=192.168.1.128/25 --gateway=192.168.1.5 --opt="com.docker.network.mtu"="1500" backend Network driver Network subnet IP range for container use. Gateway for master subnet Network name Mr.Weerayut Hongsa - @kusumoto_ton
  150. 150. Create new #docker network docker network create --driver bridge --subnet=192.168.1.0/24 --ip-range=192.168.1.128/25 --gateway=192.168.1.5 --opt="com.docker.network.mtu"="1500" backend Mr.Weerayut Hongsa - @kusumoto_ton
  151. 151. List all #docker network docker network ls Mr.Weerayut Hongsa - @kusumoto_ton
  152. 152. List all #docker network docker network ls Mr.Weerayut Hongsa - @kusumoto_ton
  153. 153. Delete #docker network docker network rm backend Mr.Weerayut Hongsa - @kusumoto_ton
  154. 154. Delete #docker network docker network rm backend Network name Mr.Weerayut Hongsa - @kusumoto_ton
  155. 155. Delete #docker network docker network rm backend Mr.Weerayut Hongsa - @kusumoto_ton
  156. 156. Run container and attach network docker run -d --name nginx --net backend --ip="192.168.1.130" -p 80:8080 nginx Mr.Weerayut Hongsa - @kusumoto_ton
  157. 157. Run container and attach network docker run -d --name nginx --net backend --ip="192.168.1.130" -p 80:8080 nginx Attach network to container Assign ip address to container Mr.Weerayut Hongsa - @kusumoto_ton
  158. 158. Run container and attach network docker run -d --name nginx --net backend --ip="192.168.1.130" -p 80:8080 nginx Mr.Weerayut Hongsa - @kusumoto_ton
  159. 159. Do you want to store and control persistent data in container? Mr.Weerayut Hongsa - @kusumoto_ton
  160. 160. Next step, we talk about #docker Volume Mr.Weerayut Hongsa - @kusumoto_ton
  161. 161. What is Docker Volume? ”Concept for manage persistent data in container” Mr.Weerayut Hongsa - @kusumoto_ton
  162. 162. Type of Data Volumes • Mount a host directory as a data volume • Mount a shared-storage volume as a data volume • Mount a host file as a data volume Mr.Weerayut Hongsa - @kusumoto_ton
  163. 163. Mount a host directory as a data volume Mr.Weerayut Hongsa - @kusumoto_ton docker run -d -v /home/kusumoto/test:/usr/share/nginx/html -p 80:80 nginx:latest
  164. 164. docker run -d -v /home/kusumoto/test:/usr/share/nginx/html -p 80:80 nginx:latest Run container background Expose port from container port 80 to local port 80 [local:container] Image Name Mapping volume to container [host:container] Mr.Weerayut Hongsa - @kusumoto_ton Mount a host directory as a data volume
  165. 165. Mount a share-storage as a data volume Mr.Weerayut Hongsa - @kusumoto_ton docker volume create --driver=flocker volumename
  166. 166. Mount a share-storage as a data volume Mr.Weerayut Hongsa - @kusumoto_ton docker volume create --driver=flocker volumename File System Driver
  167. 167. Mount a share-storage as a data volume Mr.Weerayut Hongsa - @kusumoto_ton docker container run -it –v volumename:/data busybox sh
  168. 168. Mount a share-storage as a data volume Mr.Weerayut Hongsa - @kusumoto_ton docker container run -it –v volumename:/data busybox sh Mapping file to container [share-storage:container]
  169. 169. Mount a host file as a data volume Mr.Weerayut Hongsa - @kusumoto_ton docker run --rm -it -v ~/.bash_history:/root/.bash_history ubuntu /bin/bash
  170. 170. Mount a host file as a data volume Mr.Weerayut Hongsa - @kusumoto_ton docker run --rm -it -v ~/.bash_history:/root/.bash_history ubuntu /bin/bash Mapping file to container [host:container]
  171. 171. Do you want make an easy to control multiple #docker node? Mr.Weerayut Hongsa - @kusumoto_ton
  172. 172. We’re recommend “Docker Machine” Mr.Weerayut Hongsa - @kusumoto_ton
  173. 173. Docker Machine is attached from Docker Toolbox Mr.Weerayut Hongsa - @kusumoto_ton
  174. 174. What is Docker Machine? ”The tool for management #docker node” Mr.Weerayut Hongsa - @kusumoto_ton
  175. 175. Create new #docker node docker-machine create --driver virtualbox node1 Machine Name Driver for connect Mr.Weerayut Hongsa - @kusumoto_ton
  176. 176. Driver for docker-machine are support Mr.Weerayut Hongsa - @kusumoto_ton
  177. 177. Create new #docker node docker-machine create --driver virtualbox node1 Mr.Weerayut Hongsa - @kusumoto_ton
  178. 178. List #docker node docker-machine ls Mr.Weerayut Hongsa - @kusumoto_ton
  179. 179. List #docker node docker-machine ls Mr.Weerayut Hongsa - @kusumoto_ton
  180. 180. Start #docker node by docker-machine docker-machine start node1 Mr.Weerayut Hongsa - @kusumoto_ton
  181. 181. Start #docker node by docker-machine docker-machine start node1 Machine Name Mr.Weerayut Hongsa - @kusumoto_ton
  182. 182. Start #docker node by docker-machine docker-machine start node1 Mr.Weerayut Hongsa - @kusumoto_ton
  183. 183. Stop #docker node by docker-machine docker-machine stop node1 Mr.Weerayut Hongsa - @kusumoto_ton
  184. 184. Stop #docker node by docker-machine docker-machine stop node1 Machine Name Mr.Weerayut Hongsa - @kusumoto_ton
  185. 185. Stop #docker node by docker-machine docker-machine stop node1 Mr.Weerayut Hongsa - @kusumoto_ton
  186. 186. Remove #docker node docker-machine rm node1 Mr.Weerayut Hongsa - @kusumoto_ton
  187. 187. Remove #docker node docker-machine rm node1 Machine Name Mr.Weerayut Hongsa - @kusumoto_ton
  188. 188. Remove #docker node docker-machine rm node1 Mr.Weerayut Hongsa - @kusumoto_ton
  189. 189. Show docker-machine environment docker-machine env Mr.Weerayut Hongsa - @kusumoto_ton
  190. 190. Show docker-machine environment docker-machine env Mr.Weerayut Hongsa - @kusumoto_ton
  191. 191. Connect shell to you #docker node eval "$(docker-machine env node1)" Mr.Weerayut Hongsa - @kusumoto_ton
  192. 192. Connect shell to you #docker node eval "$(docker-machine env node1)" Mr.Weerayut Hongsa - @kusumoto_ton
  193. 193. Do you think the container management very difficult? Mr.Weerayut Hongsa - @kusumoto_ton
  194. 194. Have a tooling for container management make an easy? Mr.Weerayut Hongsa - @kusumoto_ton
  195. 195. We’re recommend “Docker Compose” Mr.Weerayut Hongsa - @kusumoto_ton
  196. 196. What is Docker Compose? ”A tool for defining and running multi- container Docker applications.” Mr.Weerayut Hongsa - @kusumoto_ton
  197. 197. Docker Compose • A template for create and configuration container • YML format • Up and running in one command • Update all container in one command Mr.Weerayut Hongsa - @kusumoto_ton
  198. 198. Example docker-compose.yml version: '2' services: web: build: . ports: - "5000:5000" volumes: - .:/code redis: image: "redis:alpine" Mr.Weerayut Hongsa - @kusumoto_ton
  199. 199. Command for execute docker-compose Mr.Weerayut Hongsa - @kusumoto_ton
  200. 200. Up all container in docker-compose.yml docker-compose up -d Mr.Weerayut Hongsa - @kusumoto_ton
  201. 201. Up all container in docker-compose.yml docker-compose up -d Run all container in background Mr.Weerayut Hongsa - @kusumoto_ton
  202. 202. Up all container in docker-compose.yml docker-compose up -d Mr.Weerayut Hongsa - @kusumoto_ton
  203. 203. Down all container in docker-compose.yml docker-compose down Mr.Weerayut Hongsa - @kusumoto_ton
  204. 204. Down all container in docker-compose.yml docker-compose down Mr.Weerayut Hongsa - @kusumoto_ton
  205. 205. List container in docker-compose stack docker-compose ps Mr.Weerayut Hongsa - @kusumoto_ton
  206. 206. List container in docker-compose stack docker-compose ps Mr.Weerayut Hongsa - @kusumoto_ton
  207. 207. If your application have a many current user? Mr.Weerayut Hongsa - @kusumoto_ton
  208. 208. Do you want to scale your application? Mr.Weerayut Hongsa - @kusumoto_ton
  209. 209. We’re recommend “Docker Swarm” Mr.Weerayut Hongsa - @kusumoto_ton
  210. 210. You can scale container to multiple machine via Docker Swarm Mr.Weerayut Hongsa - @kusumoto_ton
  211. 211. Docker Swarm Mr.Weerayut Hongsa - @kusumoto_ton
  212. 212. Docker Swarm How can you control cluster? Mr.Weerayut Hongsa - @kusumoto_ton
  213. 213. Docker Swarm Choose a once node promote to manager Mr.Weerayut Hongsa - @kusumoto_ton
  214. 214. Docker Swarm Manager Mr.Weerayut Hongsa - @kusumoto_ton
  215. 215. Docker Swarm ManagerNode Node Node Node Mr.Weerayut Hongsa - @kusumoto_ton
  216. 216. Docker Swarm ManagerNode Node Node Node Mr.Weerayut Hongsa - @kusumoto_ton
  217. 217. Docker Swarm Mr.Weerayut Hongsa - @kusumoto_ton
  218. 218. Docker Swarm Mr.Weerayut Hongsa - @kusumoto_ton
  219. 219. Docker Swarm ”Run the Docker in cluster mode” Mr.Weerayut Hongsa - @kusumoto_ton
  220. 220. Docker Swarm • Scalable container to multiple docker node. • Control container multiple docker node via docker swarm manager. • In Docker swarm, you’ll have some new concepts of “services” and “tasks”. Mr.Weerayut Hongsa - @kusumoto_ton
  221. 221. Initialize Docker Swarm docker swarm init Mr.Weerayut Hongsa - @kusumoto_ton
  222. 222. Initialize Docker Swarm docker swarm init Mr.Weerayut Hongsa - @kusumoto_ton
  223. 223. Initialize Docker Swarm docker swarm init Command for join to swarm Mr.Weerayut Hongsa - @kusumoto_ton
  224. 224. Join node to your Docker Swarm docker swarm join --token SWMTKN-1-3o58oh8ahb0ebzqen63pp8dub4u91oqfy4erenaswbulih1ywr- 4xr2p6ipg2tqxeczw6cp183ob 192.168.99.100:2377 Mr.Weerayut Hongsa - @kusumoto_ton
  225. 225. Join node to your Docker Swarm docker swarm join --token SWMTKN-1-3o58oh8ahb0ebzqen63pp8dub4u91oqfy4erenaswbulih1ywr- 4xr2p6ipg2tqxeczw6cp183ob 192.168.99.100:2377 IP Address swarm manager Token Mr.Weerayut Hongsa - @kusumoto_ton
  226. 226. Join node to your Docker Swarm docker swarm join --token SWMTKN-1-3o58oh8ahb0ebzqen63pp8dub4u91oqfy4erenaswbulih1ywr- 4xr2p6ipg2tqxeczw6cp183ob 192.168.99.100:2377 Mr.Weerayut Hongsa - @kusumoto_ton
  227. 227. List all node list and node status docker node ls Mr.Weerayut Hongsa - @kusumoto_ton
  228. 228. List all node list and node status docker node ls Mr.Weerayut Hongsa - @kusumoto_ton
  229. 229. Leave node from swarm cluster docker swarm leave Mr.Weerayut Hongsa - @kusumoto_ton
  230. 230. Leave node from swarm cluster docker swarm leave Mr.Weerayut Hongsa - @kusumoto_ton
  231. 231. Create new service in swarm cluster docker service create --name nginx-web -p 80:80 nginx:latest Mr.Weerayut Hongsa - @kusumoto_ton
  232. 232. Create new service in swarm cluster docker service create --name nginx-web -p 80:80 nginx:latest Image Name Expose port from service port 80 to local port 80 [local:container] Service name Mr.Weerayut Hongsa - @kusumoto_ton
  233. 233. Create new service in swarm cluster docker service create --name nginx-web -p 80:80 nginx:latest Mr.Weerayut Hongsa - @kusumoto_ton
  234. 234. List all service in swarm cluster docker service ls Mr.Weerayut Hongsa - @kusumoto_ton
  235. 235. List all service in swarm cluster docker service ls Mr.Weerayut Hongsa - @kusumoto_ton
  236. 236. Scale up/down service in swarm cluster docker service scale nginx=3 Mr.Weerayut Hongsa - @kusumoto_ton
  237. 237. Scale up/down service in swarm cluster docker service scale nginx=3 Service name Number of container Mr.Weerayut Hongsa - @kusumoto_ton
  238. 238. Scale up/down service in swarm cluster docker service scale nginx=3 Mr.Weerayut Hongsa - @kusumoto_ton
  239. 239. Update/Apply service in swarm cluster docker service update nginx Mr.Weerayut Hongsa - @kusumoto_ton
  240. 240. Update/Apply service in swarm cluster docker service update nginx Service name Mr.Weerayut Hongsa - @kusumoto_ton
  241. 241. Update/Apply service in swarm cluster docker service update nginx Mr.Weerayut Hongsa - @kusumoto_ton
  242. 242. Delete service in swarm cluster docker service rm nginx Mr.Weerayut Hongsa - @kusumoto_ton
  243. 243. Delete service in swarm cluster docker service rm nginx Service name Mr.Weerayut Hongsa - @kusumoto_ton
  244. 244. Delete service in swarm cluster docker service rm nginx Mr.Weerayut Hongsa - @kusumoto_ton
  245. 245. Add service stack from docker-compose.yml to swarm cluster docker stack deploy --compose-file docker-compose.yml my_stack Mr.Weerayut Hongsa - @kusumoto_ton
  246. 246. Add service stack from docker-compose.yml to swarm cluster docker stack deploy --compose-file docker-compose.yml my_stack Compose file Stack name Mr.Weerayut Hongsa - @kusumoto_ton
  247. 247. Add service stack from docker-compose.yml to swarm cluster docker stack deploy --compose-file docker-compose.yml my_stack Mr.Weerayut Hongsa - @kusumoto_ton
  248. 248. Delete stack in swarm cluster docker stack rm my_stack Mr.Weerayut Hongsa - @kusumoto_ton
  249. 249. Delete stack in swarm cluster docker stack rm my_stack Stack name Mr.Weerayut Hongsa - @kusumoto_ton
  250. 250. Delete stack in swarm cluster docker stack rm my_stack Mr.Weerayut Hongsa - @kusumoto_ton
  251. 251. If you want to create your #docker image. Mr.Weerayut Hongsa - @kusumoto_ton
  252. 252. but need to customize image via script. Mr.Weerayut Hongsa - @kusumoto_ton
  253. 253. We’re recommend “Dockerfile” Mr.Weerayut Hongsa - @kusumoto_ton
  254. 254. Format of the Dockerfile # Comment INSTRUCTION arguments Mr.Weerayut Hongsa - @kusumoto_ton
  255. 255. Example Dockerfile FROM scratch COPY hello / CMD ["/hello"] Mr.Weerayut Hongsa - @kusumoto_ton
  256. 256. Example Dockerfile FROM scratch COPY hello / CMD ["/hello"] FROM microsoft/nanoserver COPY hello.txt C: CMD ["cmd", "/C", "type C:hello.txt"] Mr.Weerayut Hongsa - @kusumoto_ton
  257. 257. Dockerfile Instruction • FROM • RUN • CMD • EXPOSE • ENV • ADD • COPY • ENTRYPOINT • VOLUME • USER • WORKDIR • ARG Mr.Weerayut Hongsa - @kusumoto_ton
  258. 258. .dockerignore file • Defined filename or path ignore in docker image. • .dockerignore is same .gitignore Mr.Weerayut Hongsa - @kusumoto_ton
  259. 259. Build image from Dockerfile docker build -t kusumoto/tutu-bigo-tofblive . Mr.Weerayut Hongsa - @kusumoto_ton
  260. 260. Build image from Dockerfile docker build -t kusumoto/tutu-bigo-tofblive . Image Name Path Dockerfileparameter Mr.Weerayut Hongsa - @kusumoto_ton
  261. 261. Build image from Dockerfile docker build -t kusumoto/tutu-bigo-tofblive . Mr.Weerayut Hongsa - @kusumoto_ton

×