Quickstart with Docker
This guide provides two methods to get started with Kottster:
- Option 1: Using Docker Compose (recommended for most users)
- Option 2: Using Docker commands directly
Both the Dockerfile and docker-compose.yml are already included in the repository for your convenience.
Option 1: Using Docker Compose
1. Clone the repository
git clone https://github.com/kottster/kottster-template-js my-kottster-app
cd my-kottster-app2. Start the container
docker-compose up -dIMPORTANT: The
-dflag is crucial as it runs the container in detached mode (background). Without this flag, your terminal will be locked to the container's output, and you won't be able to run the next command to start the application.
3. Start the application
Development mode:
docker exec -it my-kottster-container /dev.shProduction mode:
docker exec -it my-kottster-container /prod.sh4. Container Management
Stop the container:
docker-compose downView container logs:
docker-compose logsOption 2: Using Docker Commands
1. Clone the repository
git clone https://github.com/kottster/kottster-template-js my-kottster-app
cd my-kottster-app2. Build the Docker image
docker build -t my-kottster-app .3. Run the container
docker run -d --name my-kottster-container \
-p 5480:5480 -p 5481:5481 \
-v $(pwd):/app \
-v /app/node_modules \
my-kottster-appHere's what each flag does:
-d- Run the container in the background--name my-kottster-container- Assign a name to the container-p 5480:5480 -p 5481:5481- Map the container ports to the host machine-v $(pwd):/app- Mount the current directory to the/appdirectory in the container-v /app/node_modules- Mount thenode_modulesdirectory to the container
4. Start the app
Development mode:
docker exec -it my-kottster-container /dev.shProduction mode:
docker exec -it my-kottster-container /prod.sh5. Container management
Stop the container:
docker stop my-kottster-containerRemove the container:
docker rm my-kottster-containerView container logs:
docker logs my-kottster-containerDevelopment
The container is configured to synchronize your local codebase with the container. Any changes made to your local files will be immediately reflected in the running application.
Configuration
Customizing Ports
With Docker Compose:
Edit the ports section in your docker-compose.yml file:
ports:
- "<host-port>:5480"
- "<host-port>:5481"With Docker commands:
Modify the -p flags in the Docker run command:
docker run -d --name my-kottster-container \
-p <host-port>:5480 -p <host-port>:5481 \
-v $(pwd):/app \
-v /app/node_modules \
my-kottster-app