Monday, August 31, 2015

Kubernetes, Docker


 This article is only to hold links and ready to use commands. You can find more in documentation.

Running Kubernetes locally via Docker 

docker run --net=host -d /usr/local/bin/etcd --addr= --bind-addr= --data-dir=/var/etcd/data
docker run --net=host -d -v /var/run/docker.sock:/var/run/docker.sock /hyperkube kubelet --api_servers=http://localhost:8080 --v=2 --address= --enable_server --hostname_override= --config=/etc/kubernetes/manifests
docker run -d --net=host --privileged /hyperkube proxy --master= --v=2

Running an application

kubectl -s http://localhost:8080 run-container nginx --image=nginx --port=80

Expose it as a service

kubectl expose rc nginx --port=80

Turn down cluster

docker ps -a | awk '{print $1}' | xargs docker kill


Show available images

docker images

Build image

docker build -t approdorix/appname .

Stop, remove containers/images

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q) 

Troubleshooting docker

You want to run screen but no tty in docker:
exec >/dev/tty 2>/dev/tty </dev/tty

No comments:

Post a Comment