This project is a Next.js starter with Docker Compose for local development.
- Docker
- Docker Compose
To start the project locally, run the following command:
docker compose up
The application will then be available at http://localhost:3000.
The application supports hot reload, so any code changes will be reflected immediately.
If you want to access the running container and install npm packages (for testing or debugging), follow these steps:
-
Find the container name:
docker ps
Look for the container running your Next.js app (e.g.,
nextjs-frame-app-1
). -
Open a shell inside the container:
docker exec -it <container-name> sh
Replace
<container-name>
with your actual container name or ID. -
Install npm packages: Inside the container, you can run:
npm install <package-name>
Note:
- Changes inside the container are temporary! For permanent changes, always run
npm install <package-name>
on your host machine, then rebuild the Docker image. - Example for permanent install:
npm install <package-name> docker compose build docker compose up
If your project folder is mounted into the container (which is the default with Docker Compose), any changes made inside the container (like installing npm packages) will be reflected on your host machine. This means you can add packages inside the running container and the changes will persist in your local package.json
and package-lock.json
.
Example:
docker exec -it <container-name> sh
npm install <package-name>
exit
After this, you will see the changes also on your host. You can then rebuild your image if needed:
docker compose build
docker compose up
To create a production build, use:
docker build -t nextjs-app .
docker run -p 3000:3000 nextjs-app
app/
- Next.js App Router filespublic/
- Static filesDockerfile
- Production Docker configurationDockerfile.dev
- Development Docker configurationdocker-compose.yml
- Docker Compose configuration