Containerization and hosting technology
Containerization is almost like having another smaller computer within a computer in the form of containers, within these containers they are completely separated from the rest of the computer. This means that actions can be performed without interacting with the rest of the machine.
I learned about this through using a Linux virtual machine running Ubuntu. in order to achieve containerization Docker was used.
Docker allows you to install things called images. Images are essentially files with all of the bits to run a piece of software. These files then need to be assembled in order to work through a Dockerfile, which can be coded in YML, also known as YAML.
The difference between a VM and a container is that a VM virtualises hardware while a container only virtualises the OS. In order to get the image on the machine (In my case a Linux VM) the following command is used.
docker pull <Insert image name>
Below is an example of a docker file written in YML to host a WordPress site
#version: '3'
services:
db:
image: mysql:8.0
container_name: wordpress_db
environment:
MYSQL_ROOT_PASSWORD: you_mysql_root_password
MYSQL_DATABASE: wordpress
MYSQL_USER: user
MYSQL_PASSWORD: pass
volumes:
- db_data:/var/lib/mysql
networks:
- wordpress_network
restart: always
wordpress:
image: wordpress:latest
container_name: wordpress_app
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: user
WORDPRESS_DB_PASSWORD: pass
ports:
- "8000:80"
volumes:
- wordpress_data:/var/www/html
depends_on:
- db
networks:
- wordpress_network
restart: always
volumes:
db_data:
wordpress_data:
networks:
wordpress_network:
driver: bridge
The aim of this file is to host a WordPress site within the container.
There are two containers one for the database and one for the WordPress site.
The whole process is not the easiest and for someone who is not experienced in programming or computer systems in general would find it much easer to pay for the process to be done for them rather than having to do it themselves.