2. Play with Docker
Play With Docker gives you the experience of having a free Alpine Linux Virtual Machine in the cloud where you can build and run Docker containers and even create clusters with Docker features like Swarm Mode.
How I can use it?
1. You need to have a Docker hub account to login, then, you can start the service.
2. After logging in, press start, and your session will start.
3. Press on + add a new instance.
4. Modify the docker-compose.yml
you created in 3. Creating a Docker Compose File (YAML) for a Spring Boot Project and PostgreSQL to pull the image of the spring boot application from the docker hub, as follows:
... #build: . #no need for this command for Docker play # using the already built image of the Spring Boot project #image: 'docker-week3:latest' image: mogharib/docker-spring-application:1.0.0 ...
5. Drag and drop the docker-compose.yml file into the browser, where the "play with docker" environment is running.
6. Check if the docker-compose.yml file has been uploaded to the environment by typing
$ ls
7. Now, we need to pull the images within the docker-compose.yml file, which can be done using the following command:
$ docker-compose pull
8. Use the following command to run the whole setup using docker-compose
$ docker-compose up -d
9. When finished, it will expose the ports of each of the services (8080 and 5432), press on port 8080, and it will open a new window where your spring boot app is running.
10. You can use this URL of the window instead of "localhost" in your HTTP request, and the application should be working as expected for each of these calls.
For example, you can use the following link for a GET all product request <url provided when you press on port:8080>/products
Note here is the docker-compose.yml.txt file for week3 application the same one you are expected to develop and use for Playwith docker. remove the .txt
extension, I have added it because the WIKI does not allow uploading *.yml
format.