Lab 03 Docker Project - AdieStevens/SYS-265 GitHub Wiki

Project Overview

  • Using Docker to host an apache web server with a mysql database.
  • Here is step by step how I did this
  • First Had to create a new directory where I would store my docker configuration files
  • Create a dockerfile for the apache web server, in the directory just created and write the following code
  • FROM httpd:2.4

COPY ./public-html/ /usr/local/apache2/htdocs/

  • This Dockerfile uses the official Apache Docker image from Docker Hub and copes the contents of the 'public-html' directory yto the Apache document root.
  • Create a public-html directory in the same directory I just created. Create file called index.html and this is going to include the content on your web server.
  • Then create a dockerfile for the MySQL database. In the same directory as your Dockerfile, and create a file called "dockerfile.mysql".
  • This Dockerfile uses the official MySQL Docker image from Docker Hub and sets some environment variables for the database. It also adds a file called mydatabase.sql to the container's initialization scripts. This file should contain the SQL commands to create your database schema and populate it with data.
  • Create a mydatabase.sql file: In the same directory as your Dockerfile, create a new file called mydatabase.sql and add some SQL commands to it to create your database schema and populate it with data
  • Then we creattet our docker-compose.yml file.
  • This docker-compose.yml file defines two services: web for the Apache web server and db for the MySQL database. The web service builds the Docker image from the current directory, which should contain the Dockerfile for the Apache server. The ports section specifies that port
  • Then you do your docker-compose up Troubleshooting
  • Make sure ports are not being used
  • Check Syntax
  • Make sure public-html is in your my-web-server original director.