From a running pod on a GKE node I can:
# docker exec e68f1765f8b0 more /etc/resolv.conf
::::::::::::::
/etc/resolv.conf
::::::::::::::
nameserver 10.103.240.10
nameserver 169.254.169.254
nameserver 10.10.0.1
search default.svc.cluster.local svc.cluster.local cluster.local c.dandsltd-gce.internal. 899692696219.google.internal. google.internal.
options ndots:5But from the same GKE node, if I run:
# docker run -it gcr.io/<same image> /bin/bash
root@ac81b13b172d:/# more /etc/resolv.conf
domain c.dandsltd-gce.internal.
search c.dandsltd-gce.internal. 899692696219.google.internal. google.internal.
nameserver 169.254.169.254
nameserver 10.10.0.1This threw me for a loop cause I thought SkyDNS was not running on my containers. Obviously, starting a pod/container from the replication controller is doing more stuff, like injecting the SkyDNS settings vs just a docker run.
Is there a way to run a one off docker container and get the same environment as a container started via the replication controller?
Thanks, Aaron
What I really just needed to do was:
# docker exec e68f1765f8b0 bashfrmo the GKE node. Then I could get a shell from a container running in the cluster instead of a new container just running locally but not provisioned by kubernetes.
This way, something like SkyDNS is setup for you and you can test something like wget .default.cluster.local etc
You can run a one off container by creating a pod with restartPolicy: Never in the spec. Example: apiVersion: v1 kind: Pod metadata: name: nginx labels: name: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 restartPolicy: "Never"
With v1.1, kubectl will support creating one-off pods from an image via kubectl run $podname --image=$image --restart=Never. In the meantime, you have to create a pod from a file to specify restart policy.