title: How to run multiple containers within the same pod in kubernetes clusture?
body: <p>I have 2 docker containers. one containing tomcat server and the other containing MySQL database. I want to run those containers on a single pod since tomcat has to access the MySQL database.</p>
  
  <p>What I have tried:</p>
  
  <p>pod.yaml</p>
  
  <pre><code>apiVersion: v1
  kind: Pod
  metadata:
    name: tomcat-mysql-pod
    labels:
    app: tomcat-mysql-pod
  spec:
  containers:
  - name: kubernetestomcatcontainer
    image: suji165475/vignesh:tomcatserver
    ports:
  - containerPort: 8080
  containers:
  - name: kubernetesmysqlcontainer
    image: suji165475/vignesh:latest
    ports:
  - containerPort: 3306
  
  </code></pre>
  
  <p>I ran this pod using</p>
  
  <pre><code>kubectl apply -f pod.yaml
  </code></pre>
  
  <p>then I exposed the pod using</p>
  
  <pre><code>kubectl expose pod tomcat-mysql-pod --type=NodePort --port=8080
  </code></pre>
  
  <p>Currently, I can only access the tomcat homepage using <code>https://serveripaddress:nodeport</code> but not my spring boot app using <code>https://serveripaddress:nodeport/data-core-0.0.1-SNAPSHOT</code>???</p>
  
  <p><strong>NOTE</strong>: The app works and ran perfectly when running the containers using docker-compose.yaml and then the docker-compose up command. But when I run this on kubernetes I get Catalina lifecycle exception in tomcat's manager app while starting my war file.</p>