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:war .

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-deployment
  labels:
    app: tomcat
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tomcat
  template:
    metadata:
      labels:
        app: tomcat
    spec:
      containers:
      - name: tomcat
        image: <REGISTRY>/<IMAGE>:<TAG>
        ports:
        - containerPort: 8080

2) service.yaml

kind: Service
apiVersion: v1
metadata:
  name: tomcat-service
spec:
  selector:
    app: tomcat
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080

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.