- Docker images:
- are a reproducible set of instructions to make a container
- are initially defined by a premade image from a registry like DockerHub
- are customised further by a
Dockerfile
- Docker containers:
- isolate a service and includes every required dependency
- are ephemeral - by default, restarting the container resets everything about the container
- Docker volumes and bind mounts:
- allow storage to be saved between restarts such as live changing code or configuration files
- volumes are stored and managed by Docker and are not easily accessible by a user
- bind mounts are stored in a location of the user's choice and are more suitable for code
- Docker networks:
- allow containers to be interacted with from the host
- allow containers to interact with eachother via an internal DNS server
- e.g. a web interface database manager such as Adminer on one container can reach another service like the database server via its service name in the
docker-compose.ymlfile.
- e.g. a web interface database manager such as Adminer on one container can reach another service like the database server via its service name in the
- Docker Compose
docker-compose.ymlfiles allow multiple containers to be built and run at once networked together.
Docker and Docker Compose installation is fairly straightforward. The installation for this has been tested on Ubuntu 20.04 as per the following guides:
- https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04
- https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-20-04
Installation for other operating systems can be found here: https://docs.docker.com/engine/install/ and https://docs.docker.com/compose/install/ .
All commands in this document will use the docker-compose command, however the newest versions of Docker Compose that were introduced during this project utilise the docker compose command. The only real difference is the base command as all arguments should still work the same.
All commands below should be executed while the command line or terminal is in the project directory that contains the docker-compose.yml file. The docker-compose command is used to interact with containers defined in a docker-compose.yml file.
-
Start specific services
external-databaseanddatabase-ui.docker-compose up -d external-database database-uiupstarts containers based on the specification indocker-compose.yml-dstarts them in the background so the terminal can be used for other things - if this is not used,Ctrl-Ccan be used to terminate the servicesexternal-databaseanddatabase-uiare services defined indocker-compose.yml, any number can be added to this command - if there are none, all services start
-
Stop containers that may have started from
docker-compose.ymlbut are in the background due to-ddocker-compose down- still retains any data that has been marked to be saved in the
volumessections of thedocker-compose.yml
- still retains any data that has been marked to be saved in the
-
Stop containers but remove all saved data (start from scratch)
docker-compose down -v- removes most saved data, may need to manually remove folders that are linked to the container
-
See logs of running containers that have been detached with
-ddocker-compose logs -f-fis short for--followand allows new logs to keep showing while in this view- Terminating the process with
Ctrl-Chere will only close the log window, not terminate the services
-
In order to run commands inside a running container,
execcan be useddocker-compose exec web npm testwebis an example container to execute a command innpm testis the example command to run- this is the primary method to run tests for the web container
-
runis much likeexecexcept it does not require the container to be running beforehanddocker-compose run web npm install new_dependencynpm install new_dependencyis the example command here- this is the primary method for adding a new dependency
-
Sometimes new dependencies will not register with the app, there are two commands to mitigate this:
docker-compose down -v docker-compose build web- the first command brings down the containers and removes any volumes, this helps remove the node_modules cache
- the second command forces the container to rebuild and consider the new
package.jsonfile.
All the ports that are exposed are documented in the docker-compose.yml file here.
- the main web module can be accessed at http://localhost:3030
- the internal database is exposed with port 33062
- the external development database is exposed with port 33061
- the adminer database manager instance can be found at http://localhost:8080
Authentication is managed by the external provider Auth0. Most of the user management can be managed within the application itself, however additional functionality and for transparency, access directly to the Auth0 platform is provided here. The Auth0 associated account can only be accessed via the provisioned Gmail account. The Gmail account for this application is ***REMOVED*** with password humber_bridge. Using these details via the Login With Google button on the Auth0 website, all the user management can be accessed.
As this user database is being used for both development and production, extreme care should be taken to ensure production users aren't affected. The default login for the actual application is:
- Email: REMOVED
- Password: REMOVED
The machine learning can be triggered by going to http://localhost:5000
- The MySQL and Postgres containers runs any
.sqlfiles that it has in/docker-entrypoint-initdb.dfolder within the container. - To put files in this directory, a volume has been made with
volumes: - ./external-database/init:/docker-entrypoint-initdb.d
the volume puts files from the localvolumes: - ./internal-database/init:/docker-entrypoint-initdb.d
initdirectory insideexternal-databasefolder into the entrypoint directory in the container. - The container only runs the
.sqlfiles on the first instance.