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

Docker 4 WordPress

Docker 4 WordPress

This was a talk about using Docker for local WordPress development given in Zrenjanin, Serbia on April 28, 2017.

A9934ebac3d430f4b6c7b215d07081ed?s=128

Mladen Đurić

April 28, 2017
Tweet

Transcript

  1. 1

  2. THE THEORY OF EVERYTHING AND VERY BRIEFLY ABOUT DOCKER IN

    
 WORDPRESS DEVELOPMENT Mladen Đurić @macmladen 2 5. MeetUp Zrenjanin 2017
  3. Mladen Đurić @MacMladen 3 5. MeetUp Zrenjanin 2017

  4. DOCKER 4 WORDPRESS IN DEVELOPMENT & PRODUCTION Mladen Đurić @macmladen

    4 5. MeetUp Zrenjanin 2017
  5. MLADEN ĐURIĆ a.k.a MacMladen • in IT since the time

    of mainframes, 8th year in UNIX epoch (that’s 1978). • started with Z80 assembly, went over 6502 to 8086 (1978-1990) • somewhere in between, there was an episode with BASIC but really enjoyed hard core C • was knee deep in DTP 1990-2000 • gone to Mac in 1995 and never looked back • 2005 started playing with web technologies with WPMU but figured out it is not flexible enough • 2007 landed on Drupal 5 5. MeetUp Zrenjanin 2017
  6. WPMU ?! Mladen Đurić @macmladen 6 5. MeetUp Zrenjanin 2017

  7. TIMETABLE: 1. The Problem ~5 min 2. The Virtualization ~5

    min 3. The Docker ~10 min 4. The Solution ~10 min 5. The Practice ~10 min 6. The Orchestration ~10 min 7. Q & A: 10 min or more 7 5. MeetUp Zrenjanin 2017
  8. 8 5. MeetUp Zrenjanin 2017

  9. 9 WHEN IN ROME,
 DO AS THE ROMANS DO ‘I

    no longer craziest developer. Lol.’ 5. MeetUp Zrenjanin 2017
  10. Chapter 1. THE PROBLEM 10 5. MeetUp Zrenjanin 2017

  11. …JUST ONE?! 1. System setup - for development 2. Project

    setup - matching production 3. Quick fix of the old one - matching what was 4. Project setup - for a colleague 5. Project weirdos - matching production 6. Project requirements - one is 5.3 other 5.6, and 7.1… 7. System upgrade - what the !#$%&%$ happened to ___ 8. Testing - would that work under… 9. Archiving - I know what I did last summer but before that..!? 11 5. MeetUp Zrenjanin 2017
  12. Chapter 2. THE VIRTUALIZATION 12 5. MeetUp Zrenjanin 2017

  13. TYPES OF VIRTUALIZATION 13 1. Full virtualization almost as a

    physical machine 2. Hypervisor runs different OSes 3. Isolation runs OSes on same kernel 5. MeetUp Zrenjanin 2017
  14. FULL VIRTUALIZATION 14 5. MeetUp Zrenjanin 2017

  15. HYPERVISOR 15 5. MeetUp Zrenjanin 2017

  16. FULL / HYPERVISOR 16 5. MeetUp Zrenjanin 2017

  17. CONTAINERIZATION 17 5. MeetUp Zrenjanin 2017

  18. CONTAINERIZATION 18 5. MeetUp Zrenjanin 2017

  19. Chapter 3. THE DOCKER 19 5. MeetUp Zrenjanin 2017

  20. INSTALLATION 20 5. MeetUp Zrenjanin 2017

  21. INSTALLATION 21 Docker Engine is supported on Cloud, Linux. Windows

    and Mac OS have native docker application. wget -qO- https://get.docker.com/ | sh docker –version Docker is treated like other services. sudo service docker status
 sudo service docker start Test the installation using this code sudo docker run ubuntu:14.04 /bin/echo 'Hello world' 5. MeetUp Zrenjanin 2017
  22. https://hub.docker.com/ 22 5. MeetUp Zrenjanin 2017

  23. docker 23 sudo docker run -d -p 8080:80 --name apache

    --link mysql:mysql -v /var/www/html:/var/www/html jessecascio/ local:apache # verify the two containers are running, and link exists sudo docker ps sudo docker inspect -f "{{ .HostConfig.Links }}" apache 5. MeetUp Zrenjanin 2017
  24. docker-compose 24 version: '2'
 
 services:
 db:
 image: mysql:5.7
 volumes:


    - db_data:/var/lib/mysql
 restart: always
 environment:
 MYSQL_ROOT_PASSWORD: wordpress
 MYSQL_DATABASE: wordpress
 MYSQL_USER: wordpress
 MYSQL_PASSWORD: wordpress
 
 wordpress:
 depends_on:
 - db
 image: wordpress:latest
 ports:
 - "8000:80"
 restart: always
 environment:
 WORDPRESS_DB_HOST: db:3306
 WORDPRESS_DB_PASSWORD: wordpress
 volumes:
 db_data: The official docker-compose.yml for WordPress looks like this: 5. MeetUp Zrenjanin 2017
  25. docker and docker-compose commands 25 docker controls individual containers by

    name or ID while docker-compose controls a group of containers, usually called application or stack. Usual Docker commands: docker ps -a — lists all docker containers, running, paused and stopped. docker inspect mcidev_nginx_1 — lists all details about the container by name or ID docker stats --no-stream — shows resource usage, omit --no-stream to have live stats docker-compose up -d — while in directory structure containing docker-compose.yml, creates and starts application. docker-compose pull — fetch latest version of containers. docker-compose stop — stops application docker-compose start — starts application docker-compose restart — restarts application docker-compose down — remove containers (instance of contaners images) 5. MeetUp Zrenjanin 2017
  26. Dockerfile 26 The Apache Dockerfile can look like this. FROM

    ubuntu:14.04 RUN apt-get update RUN apt-get install -y apache2 RUN apt-get install -y php5 php5-common php5-cli php5-mysql php5-curl EXPOSE 80 CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"] 5. MeetUp Zrenjanin 2017
  27. Chapter 4. THE SOLUTION 27 5. MeetUp Zrenjanin 2017

  28. Chapter 5. THE PRACTICE 28 5. MeetUp Zrenjanin 2017

  29. Chapter 6. THE ORCHESTRATION 29 5. MeetUp Zrenjanin 2017

  30. 30 Mladen Đurić @macmladen Q & A DOCKER4WORDPRESS 5. MeetUp

    Zrenjanin 2017
  31. THANKS! DOCKER4WORDPRESS Mladen Đurić @macmladen 31 5. MeetUp Zrenjanin 2017