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

Docker based Web development

Docker based Web development

This is my introductory talk on Docker that I gave on 6th WordPress meetup in Novi Sad in StartIt center.

https://www.meetup.com/WP-Meetup-NS/events/236189966

The story about the docker is just too complex to be covered up with a single 30 minute talk, so I gave an overview on virtualization technologies and how is the docker positioned there.

Included in presentation, I showed practically how easy it is to start a container once the docker application is installed.

It enables both Windows and Mac to have seamless development integration of PHP, web server and database but also Linux would benefit from isolation of environments for different projects.

Get the docker here: https://www.docker.com/

Once installed, check WordPress quick start here https://docs.docker.com/compose/wordpress/

Just follow that quick start and you will be up and running in no time ;)

If you wish to discuss matters with me, you may wait for another live presentation or catch me somewhere online, I'm easy to find and always in a good mood for a discussion on any matter.

Mladen Đurić

April 17, 2017
Tweet

More Decks by Mladen Đurić

Other Decks in Programming

Transcript

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

    
 WORDPRESS DEVELOPMENT Mladen Đurić @macmladen 1 6. MeetUp Novi Sad 2017
  2. 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 4 6. MeetUp Novi Sad 2017
  3. TIMETABLE: 1. The Problem ~5 min 2. The Virtualization ~5

    min 3. The Docker ~10 min 4. The Solution ~10 min 5. Q & A: 10 min or more 6 6. MeetUp Novi Sad 2017
  4. 8 WHEN IN ROME,
 DO AS THE ROMANS DO 6.

    MeetUp Novi Sad 2017 ‘I no longer craziest developer. Lol.’
  5. …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..!? 10 6. MeetUp Novi Sad 2017
  6. TYPES OF VIRTUALIZATION 12 6. MeetUp Novi Sad 2017 Full

    virtualization almost as a physical machine Hypervisor runs different OSes Isolation runs OSes on same kernel
  7. INSTALLATION 19 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' 6. MeetUp Novi Sad 2017
  8. docker 22 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 6. MeetUp Novi Sad 2017
  9. Dockerfile 23 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"] 6. MeetUp Novi Sad 2017
  10. 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: 6. MeetUp Novi Sad 2017 The official docker-compose.yml for WordPress looks like this:
  11. docker and docker-compose commands 25 6. MeetUp Novi Sad 2017

    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)