Docker
When working on a project most of the time you are making use of a lot of different tools. For example, you might be using a database, a message broker, a cache, etc. All these tools need to be installed and configured on your machine. This can be a tedious task and can take a lot of time. Docker is a tool that can help you with this. Docker allows you to run applications in containers. A container is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings.
In the Individual Project of Internet of Things you are building a website which exists of a front-end, API, database, tunnel, ... a lot. To help you with this you will be using Docker. On this page you can find information about how to set-up the docker environment for your project, in your Gitlab project.
Contents
There are already files/folder in your Gitlab project for docker, some to point out:
docker-compose.yml
: This file contains the configuration for your docker environment. It contains the services that will be running in your docker environment. For example; nginx, php, mysql, ...docker/
: This folder contains the configuration for the different services. For example; nginx, php, mysql, ....env
: This file contains the environment variables that will be used in your docker environment. For example; HvA username, MySQL password, ...
Running docker on your computer
To run docker on your computer you need to install Docker Desktop. You can find the installation instructions on the Docker website.
After installation you have to change the configuration in the .env
-file. Make sure you enter your HvA username (for example: vriesd19). This will be used to create a unique name for your docker environment.
Usage
To start your docker environment you can run the following command in your terminal, from your project root:
1 |
|
or to rebuild the docker environment:
1 |
|
This will create the docker containers and run them automatically. You can check if the containers are running by opening your webbrowser and visiting http://localhost.
Part of the docker is a dashboard for your tunnel, you can find this on http://localhost/dashboard.
Services
By default you can find the following services in your docker environment:
- Nginx (port 80)
- PHP
- MariaDB (MySQL) (port 3306)
- PhpMyAdmin
- Tunnel
Make sure you are not running any other services on these ports.
MariaDB (MySQL)
The details of your MySQL database are:
Key | Value |
---|---|
hostname | mariadb |
user | root |
password | [You can find the password in the .env -file. ] |