Running an application with Docker Compose
Once we have built our images, we can start the application using Docker Compose:
$ docker compose up
The output, similar to the output we discussed in the previous section for the db
and pgadmin
services, will look as follows for the web
service:
step2-web-1 | DB_HOST: dbstep2-web-1 | Application listening on port 3000
This indicates that the containerized web
service is ready and is listening on port 3000
. Coincidentally, we have mapped container port 3000
to the same port 3000
on the host in our docker-compose.yml
file. Thus, we can just open a new browser tab and navigate to the URL http://localhost:3000/animal; we should once again see a wild animal displayed.
Refresh the browser a few times to see other animal images. The application selects the current image randomly from a set of 12 images whose URLs are stored in the database.
As the application...