0

I have built a tomcat image using the following dockerfile

FROM tomcat
COPY data-core.war /usr/local/tomcat/webapps/

then I built it using

docker build --no-cache -t tomcat:warfile .

Now how do I link a container based off this image with another container having mysql installed in it. Iam not really sure how the tomcat container can interact with the mysql database container.

Then finally i want to deploy/overlay this using kubernetes using the following yaml files for deployment and service.

1) deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: tomcat-pod
spec:
  selector:
    matchLabels:
      run: tomcat-pod
  replicas: 1
  template:
    metadata:
      labels:
        run: tomcat-pod
    spec:
      containers:
      - name: tomcat
        image: tomcat:warfile
        ports:
        - containerPort: 8080

2) service.yaml

apiVersion: v1
kind: Service
metadata:
  name: tomcat-pod
  labels:
    run: tomcat-pod
spec:
  type: NodePort
  ports:
  - port: 8080
    targetPort: 8080
  selector:
    run: tomcat-pod

are the yaml files correct or do i have to specify something within those yaml files for connecting the application container to the mysql container??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.