-
Docker build command
docker build -t employee .
-
Docker run command
docker run -p 8080:8080 employee
--> run docker in the background
docker run -d -p 8080:8080 employee-api
-
Access the H2 console to verify the database setup:
Open your web browser and go to http://localhost:8080/h2-console.
Use the following details to log in:
a. JDBC URL: jdbc:h2:mem:testdb
b. Username: sa
c. Password: password -
Test the Application
Use tools like Postman or Curl to test the API endpoints:
GET all employees: GET http://localhost:8080/api/employees
GET an employee by ID: GET http://localhost:8080/api/employees/{id}
POST a new employee: POST http://localhost:8080/api/employees
PUT update an employee: PUT http://localhost:8080/api/employees/{id}
DELETE an employee: DELETE http://localhost:8080/api/employees/{id}
- Verifying the Container is Running
A. List Running Containers:
You can list all running containers using:
docker ps
This will show you all the containers that are currently running, including the employee-api container.
B. Check Logs:
To check the logs of the running container (replace <container_id> with the actual container ID from the docker ps output):
docker logs <container_id>
C. Stopping the Container
If you need to stop the container, you can do so with:
docker stop <container_id>
D. To remove the container after stopping it, use:
docker rm <container_id>
- Access the swagger ui
http://localhost:8080/swagger-ui/index.html