# Setup JSP Tomcat Docker from GitHub Gist

# \[1\] Start Your Docker Playground

Create a new instance.

# \[2\] Prepare the Setup Script

In the terminal window, type:

```bash
touch get-setup-script.sh
```

Click the **Editor** button at the top of the terminal window.

In the editor, open the file `get-setup-script.sh`.

Paste the following code into the file:

```bash
curl -fsSL https://gist.githubusercontent.com/mohamadrazzimy/da1c5df7e8160ae03bbde499f4b1b516/raw/6932c9cd6d70bc40d9e84c830bc8df94367e2218/setup-jsp-tomcat-docker.sh -o setup-jsp-tomcat-docker.sh
```

Example:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766286168491/7eef9192-2891-424e-898c-f27ccd777816.png align="center")

To execute the script, run the following command:

```bash
bash get-setup-script.sh
```

This will download the `setup-jsp-tomcat-docker.sh` file to the root directory. You can verify this by using the `ls` command.

Example:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766286529724/02da7842-cc02-45c6-8b04-90476e6807f3.png align="center")

# \[3\] Run the Setup Script

Execute the setup script by running:

```bash
bash setup-jsp-tomcat-docker.sh
```

This script will download a zipped project from GitHub and unzip it.

Example:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766286774973/e852d31e-eeb7-4c05-8179-703301ffcc16.png align="center")

Notice the folder `jsp-tomcat-docker-main`.

# \[4\] Run the Docker Compose Script

Navigate to the project folder using the `cd` command.

Check the contents of the folder with the `ls` command.

Example:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766286884155/3d77c542-580e-4346-8931-c80d0ed75e59.png align="center")

You should notice a file named `docker-compose.yml`.

To launch the Docker containers, run:

```bash
docker-compose up -d
```

Example:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766287209271/59ea1179-4c77-4db9-822e-f009fcbc08da.png align="center")

You can verify using the following command:

```bash
docker ps
```

Example:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766287290115/90864270-44cc-4725-bc39-3bd7b0f8887f.png align="center")

You should see a clickable button for port 8080 at the top of the page.

If it doesn’t appear, click the **OPEN PORT** button, enter 8080, and you should be able to access the port via your web browser.

Example:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766287337252/68430fc9-96b0-4441-9d66-a74b54a03206.png align="center")

You should see the following page:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766287442250/a4a9de12-14a6-4080-9149-ebc9be9b3f86.png align="center")

---

# APPENDIX

### \[1\] docker-compose.yml

```bash
version: '3.8'

services:
  tomcat:
    image: tomcat:9-jdk17
    ports:
      - "8080:8080"
    volumes:
      - ./webapp:/usr/local/tomcat/webapps/ROOT
    # Optional: Wait for startup to complete before marking as "healthy"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080"]
      interval: 10s
      timeout: 5s
      retries: 5
```

### \[2\] webapp/index.jsp

```bash
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head><title>Hello JSP</title></head>
<body>
  <h1>Hello from Docker Compose!</h1>
  <p>Server time: <%= new java.util.Date() %></p>
</body>
</html>
```
