WordPress with Docker
Workshop
Devarshi Sathiya Imran Sayed
What do I need to know to learn Docker?
● At Least know to use the command line usage and tools
What is Docker?
● Docker is an open-source software
platform for building container based
applications ( started in 2013 )
● It carves up a computer into sealed
containers that run your code.
● Containers are small and lightweight
execution environments that make
shared use of the operating system
kernel but otherwise run in isolation
from one another
Docker in a nutshell
Computer
You Interact with a client-program
name docker cli
Docker needs a Linux server to manage - so we run linux serve in a virtual machine
Server-program - docker host
Interact with a
server-program
name docker host Linux Virtual Machine
Docker Desktop
For Mac For Windows
Docker build
Docker pull
More about Docker
● Docker is a client-program that you
run from the terminal
● Docker is also a server program that
manages the linux system
● Its a program that takes your code
bundles it up and seals into a
container.
● Docker is also a service that
distributes containers so people can
share their work.
Why Docker?
● Developing apps today can require multiple languages,
frameworks, architectures.
● Docker simplifies and accelerates your workflow.
● It gives developers the freedom to innovate with their choice
of tools, application stacks, and deployment environments for
each project
Why Docker?
● Simplicity - Docker’s friendly, CLI-based workflow makes
building, sharing, and running containerized applications
accessible to developers of all skill levels.
● Agile - Install from a single package to get up and
running in minutes. Code and test locally while ensuring
consistency between development and production.
● Collaborate -Use Certified and community-provided
images in your project. Push to a cloud-based
application registry and collaborate with team members.
Docker today
Docker Containers Are Everywhere:
Linux, Windows, Data center, Cloud, Serverless, etc.
Docker Vs Virtual Machines
Docker Flow
Image
A file that makes up just enough
OS that you need
Running
Container
A container is an image that has
process running in it
Docker run
Stopped
Container
A container that has the process
stopped running.
New Image
Docker commit
New image created
from the exited container
Creates a new container
Docker
kill
What is Docker Container?
● A self-contained sealed unit of
software
● Contains everything needed to run the
service.
● It bundles together all the code,
config, processes, networking,
dependencies and just enough
operating system to run your code.
Docker installation
Install Docker
● Docker Desktop - on Mac and Windows
● Docker on Ubuntu
Creating a container
What is docker
compose?
docker run -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=wordpress --name
wordpressdb -v "$PWD/database":/var/lib/mysql -d mariadb:latest
Setting up WordPress
with Docker
version: '3.3'
services:
composer:
image: composer
command: update
volumes:
- ./wordpress:/app
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
volumes:
- ./mysql:/var/lib/mysql
phpmyadmin:
image: phpmyadmin/phpmyadmin
depends_on:
- mysql
environment:
PMA_HOST: mysql
PMA_PORT: 3306
PMA_ARBITRARY: 1
restart: always
ports:
- 8183:80
wordpress:
depends_on:
- mysql
- composer
image: wordpress:latest
ports:
- "8020:80"
restart: always
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
Demo
● Deploy on local
● Show WordPress on :8020
● Show phpMyAdmin
References
● https://techio.dev/docker/docker-for-kids.html
● https://techio.dev/docker/docker-networks-and-volumes.html
● https://www.docker.com/blog/containers-replacing-virtual-
machines/