Reputation: 41
I am having some trouble converting my docker setup to kubernetes. I have read the kubectl for docker users, have set up minikube and am trying to autoscale my docker application with kubernetes. But I am having some trouble just running it.
I am trying to make a container with a python flask application on centos image that uses a database that I have setup in the cloud
In docker I would just use the docker build . -tag and then use docker run to setup my container. like so:
This would give me a container on port 5000 (For the Database I have to use the hostnetwork als it needs an ip to work with. setting localhost 127.0.0.1:5000 doesnt seem to work, but that is another issue in itself)
When I read the Kubectl documentation for docker users it would seem like i can do almost the same I do with docker in Kubernetes. So I am trying this.
I haven't figured out how to use --network host in kubernetes but I thought just running it and see if it gave an error. And it did. It seems not to be able to pull the image. but docker can. What is going wrong here?
after a while it just goes to.
I haven't even tried horizontal autoscaling yet, nor do I understand the docker-file convert yet. But i should be able to just run the container right?
EDIT: I used windows to generate the screenshots.
Commands I am running:
docker run --network host -d hu-simple:latest
output I am getting:
a docker deamon string because it created a docker container for me
Commands in Kubernetes I am trying:
kubectl run --image=hu-simpel:latest hu-simpel --port=5000
output i am getting:
deployment.apps/hu-simpel created
But when I try kubectl get all:
I get: ErrImagepull and ImagePullBackOff after a while.
I don't think I am using a kubernetes deployment yaml as I am just trying to run a docker image on kubernetes. I didnt create it in kubernetes using a docker-compose but just tried to run the docker image. But do tell me if I am mistaken.
Upvotes: 0
Views: 195
Reputation: 797
This happens because your minikube instance is not able to reach your Docker daemon. In other words, your Kubernetes doesn't know anything about the images you built using your host Docker.
To solve this, you have this command: minikube docker-env
. This will export everything from Docker to your minikube instance, meaning that you'll be able to reuse the images you build in your host.
When you finish you can do docker-machine env -u
.
Upvotes: 3