Running the Node.js App in Docker
💡 If PostgreSQL is already running locally, you may need to free up port 5432 before proceeding.
- Check for any processes running on port 5432:
sudo lsof -i :5432This command lists all processes using port 5432 along with their process IDs (PID).
- Terminate the process using port 5432: If any processes are listed, stop them by running:
sudo kill -9 <pid>Replace pid with the actual process ID from the previous command's output.
To get our Node.js app up and running in a Docker container, simply run the following command in the root directory:
npm run docker:composeDocker will begin building the two images defined in the docker-compose.yml file:
backend-devfor the backendpostgres-dbfor the database.

After the images are successfully built:
- It will start reading the
Dockerfile.dev - Install dependencies
- Prisma will automatically run any necessary database migrations
- The database will be seeded with initial data to get things started
When everything is set, you’ll see the following message, indicating that your server is up and running:

Next, let's take a look at our Docker desktop app:
- On the containers tab, it's running two containers for our backend and also Postgres.

- On the Images tab, it created two images defined in our
docker-compose.yml:

Great! Now let's access our localhost:4000 (opens in a new tab) from the browser. You should be able to see our welcome message:
Welcome to AWSLaunchGOAT!!!
If you access the /users route at localhost:4000/v1/users, you will see seeded data.
