Back after a while with some interesting stuff!
A few months ago, i was assigned to make a free-topic project for Networks and Cloud Technologies class at my University’s Department of Information
& Communication Systems Engineering. Me and my team (Manolis Andreopoulos and Nikos Valakitsis) decided to get involved with Docker.
We wanted to start and make something simple so we tried to implement a sample of a Digital Library. The components were a MySQL container for the database that stores the information about the books such as ISBN , Title and Author. This was pretty easy to do because the “ready” image that is hosted at Docker Hub has a lot of documentation on how you can use it directly for your project’s implementation. So using some basic commands from the documentation the DB was ready and we can see the result at MySQL Workbench.
The next we had to to was to host the .pdf files that will be the actual books that a user was going to read. We thought a simple solution of hosting those files in an apache server under www/ directory. The simple docker commands to do this are the following:
1) docker run -it georgemakrakis/ubuntu-storage (running the initial container from a ready image)
2) cp C:/Users/nikos/Desktop/books 25bd8bd628b2:/var/www/html/books (copoying the files from host into the container)
3) docker run -itd –name storage_a -p 8181:8181 georgemakrakis/ubuntu-storage) -and docker exec -itd storage_a service apache2 start (staring the container at port 8181 and excecuting apache2 inside it)
The result is the following:
In the end we decided that the interface will be a web app that will only displays the simple data from the previous two containers. Java’s Spring Boot Framework helped us to that thing using the ease of the MVC architecture pattern. Connecting the database to the app by using a simple JDBC driver fro MySQL to perform CRUD operations and writing a Model and a Controller as shown below we managed to see our result into a web browser
(also the build of the docker spring-image was made using the maven plug-in and a docker-file with these commands:
1)cd Desktop/library
2)mvn clean install
3)The copping jar from target to src / main / docker /
4)sudo docker build -t library_app src/main/docker/ (buils the dockerrfile)
5)sudo docker run –net=host -p 8080:8080 -t library_app )
Also to mention that, we also worked on different platforms (Windows and Linux) before the final integration in one server, using the portability that docker and docker hub provide.
So it was a nice and simple experience to get in touch with Docker for the very first time and we will be sure get involved again with this technology in the future. 😀