How to create a pod from existing docker container

2/18/2019

I have created a docker container using docker-compose.yml and it is running on 8085/tcp. Now i need to create a pod with this container and deploy it with kubernetes. I used .yaml file to do so but i am getting a CrashLoopBackOff error.

$ docker ps
CONTAINER ID           IMAGE                STATUS              PORTS                 NAMES
b155297cad73  wpt-rest_wptrestservice      Up 4 hours    0.0.0.0:8085->8085/tcp   wpt-rest_wptrestservice_1


$ docker container ls
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                    NAMES
b155297cad73        wpt-rest_wptrestservice     "java -jar wpt-rest.…"   4 hours ago         Up 4 hours          0.0.0.0:8085->8085/tcp   wpt-rest_wptrestservice_1

Now i created a wpt-pod.yml file:

apiVersion: v1
kind: Pod
metadata:
  name: wpt-pod
spec:
  containers:
    - name: wptrestservice
 image: localhost:5000/local-openjdk:latest
ports:
- containerPort: 8085

But after running the above .yaml file i am getting the following error :

$ kubectl get pods
NAME                    READY   STATUS             RESTARTS   AGE    
wpt-pod                 0/1     CrashLoopBackOff   2          35s

What am i doing wrong here? I am new to kubernetes and got here by following some online tutorials.

-- Jerrin Thomas
docker
kubernetes
kubernetes-cluster
kubernetes-pod
yaml

0 Answers