Ensure that the Elasticsearch container is running and that it has bound its port to our local machine. Then, run our hobnob image using docker run:
$ docker run --env-file ./.env --name hobnob -d -p 8080:8080 hobnob:0.1.0
Note that we are using the --env-file option to pass in our environment variables at runtime instead of build time.
To check that our container is running without errors, check the stdout produced inside the container, which we can conveniently check using docker logs:
$ docker logs hobnob
yarn run v1.5.1
$ node dist/index.js
Hobnob API server listening on port 8080!
If the container's log does not show the preceding success message, go back and repeat the steps closely. You may want to use docker stop hobnob and docker rm hobnob to stop and remove the container, and docker rmi hobnob to remove the image. You may also enter into the container (like with SSH) by executing docker exec -it hobnob bash.
Assuming everything is up and running, we’d still need to check that the application is actually functional by querying the API using curl:
$ curl localhost:8080/users
[]
$ curl -X POST http://localhost:8080/users/ \
-H 'Content-Type: application/json' \
-d '{
"email": "e@ma.il",
"digest": "$2y$10$6.5uPfJUCQlcuLO/SNVX3u1yU6LZv.39qOzshHXJVpaq3tJkTwiAy"}'
msb9amMB4lw6tgyQapgH
$ curl localhost:8080/users
[{"email":"e@ma.il"}]
This means that the request from our host has successfully reached our application, and that the application can successfully communicate with our database!