Docker namespaces

Jason Snape:
Hi, Quick question, when I run the ‘docker ps’ command I only see containers in the kube-system namespace, if I describe a pod I can see a docker container ID but this doesn’t work with the command docker logs <container ID>. I also can’t see anything in the Docker documentation, how can I see Docker logs for containers I create in different namespaces? Thanks, Jason

Rahul Soni:
hello Jason, have you tried command, docker ps -a ?

Jason Snape:
Hi Rahul, yes, it only shows exited containers from the kube-system namespace.

Jason Snape:
[email protected]:/home/osboxes# k get po
nginx 1/1 Running 3 4d20h
nginx2 1/1 Running 0 3h12m
nginx2-669c86457c-rdj5l 1/1 Running 0 3h11m
redis 1/1 Running 3 4d23h
[email protected]:/home/osboxes# docker ps -a
362d9d6fed43 67da37a9a360 “/coredns -conf /e…” 6 hours ago Up 6 hours k8s_coredns_coredns-66bff467f8-nhwkh_kube-system_7ab7cbd8-3062-4851-93d0-5d4e58491ec9_83
441264b6f952 67da37a9a360 “/coredns -conf /e…” 6 hours ago Up 6 hours k8s_coredns_coredns-66bff467f8-wqpg9_kube-system_114efaf0-fcc1-49c6-a7ca-f80db87e4d25_83
c8beea85028f| “/pause” 6 hours ago Up 6 hours k8s_POD_coredns-66bff467f8-wqpg9_kube-system_114efaf0-fcc1-49c6-a7ca-f80db87e4d25_229
b14fe59f46fa| “/pause” 6 hours ago Up 6 hours k8s_POD_coredns-66bff467f8-nhwkh_kube-system_7ab7cbd8-3062-4851-93d0-5d4e58491ec9_230
6a29e578eec1 4e9f801d2217 “/opt/bin/flanneld…” 6 hours ago Up 6 hours k8s_kube-flannel_kube-flannel-ds-amd64-2gfb2_kube-system_8758da21-9de1-4c14-a294-4820eb26773d_38
c44463c47395 4e9f801d2217 “cp -f /etc/kube-f…” 6 hours ago Exited (0) 6 hours ago k8s_install-cni_kube-flannel-ds-amd64-2gfb2_kube-system_8758da21-9de1-4c14-a294-4820eb26773d_25
1716f58f9ae7 0d40868643c6 “/usr/local/bin/ku…” 6 hours ago Up 6 hours k8s_kube-proxy_kube-proxy-268rk_kube-system_fca74108-d0d2-43ff-b5f7-a59decabbf7a_25
e5cdcf499249| “/pause” 6 hours ago Up 6 hours k8s_POD_kube-flannel-ds-amd64-2gfb2_kube-system_8758da21-9de1-4c14-a294-4820eb26773d_25
802053d8ea2f| “/pause” 6 hours ago Up 6 hours k8s_POD_kube-proxy-268rk_kube-system_fca74108-d0d2-43ff-b5f7-a59decabbf7a_25
8afb249cd9ba ace0a8c17ba9 “kube-controller-m…” 6 hours ago Up 6 hours k8s_kube-controller-manager_kube-controller-manager-kubemaster_kube-system_7e7a524bbe609be08615d12902ca2d8c_45
6bd16f676372 a3099161e137 “kube-scheduler --…” 6 hours ago Up 6 hours k8s_kube-scheduler_kube-scheduler-kubemaster_kube-system_155707e0c19147c8dc5e997f089c0ad1_42
5adb15e7e214 303ce5db0e90 “etcd --advertise-…” 6 hours ago Up 6 hours k8s_etcd_etcd-kubemaster_kube-system_114a3b7d9915e80a91de886a97d78b39_26
15fa3536c366 6ed75ad404bd “kube-apiserver --…” 6 hours ago Up 6 hours k8s_kube-apiserver_kube-apiserver-kubemaster_kube-system_b7e2454e20d7d57ed4c269f01b412dbe_27
bb5ce4a5aa00| “/pause” 6 hours ago Up 6 hours k8s_POD_kube-controller-manager-kubemaster_kube-system_7e7a524bbe609be08615d12902ca2d8c_25
69314136121b| “/pause” 6 hours ago Up 6 hours k8s_POD_kube-apiserver-kubemaster_kube-system_b7e2454e20d7d57ed4c269f01b412dbe_25
cef786795ca3| “/pause” 6 hours ago Up 6 hours k8s_POD_etcd-kubemaster_kube-system_114a3b7d9915e80a91de886a97d78b39_25
ca57521c9729| “/pause” 6 hours ago Up 6 hours k8s_POD_kube-scheduler-kubemaster_kube-system_155707e0c19147c8dc5e997f089c0ad1_25
e3f3c6d9df81 a3099161e137 “kube-scheduler --…” 23 hours ago Exited (255) 6 hours ago k8s_kube-scheduler_kube-scheduler-kubemaster_kube-system_155707e0c19147c8dc5e997f089c0ad1_41
d090666d7425 ace0a8c17ba9 “kube-controller-m…” 23 hours ago Exited (255) 6 hours ago k8s_kube-controller-manager_kube-controller-manager-kubemaster_kube-system_7e7a524bbe609be08615d12902ca2d8c_44
9e0834756adf 67da37a9a360 “/coredns -conf /e…” 23 hours ago Exited (255) 6 hours ago k8s_coredns_coredns-66bff467f8-wqpg9_kube-system_114efaf0-fcc1-49c6-a7ca-f80db87e4d25_82
2745041b09ac 67da37a9a360 “/coredns -conf /e…” 23 hours ago Exited (255) 6 hours ago k8s_coredns_coredns-66bff467f8-nhwkh_kube-system_7ab7cbd8-3062-4851-93d0-5d4e58491ec9_82
0eaaeec004e9| “/pause” 23 hours ago Exited (255) 6 hours ago k8s_POD_coredns-66bff467f8-wqpg9_kube-system_114efaf0-fcc1-49c6-a7ca-f80db87e4d25_225
d6d40e5e2e14| “/pause” 23 hours ago Exited (255) 6 hours ago k8s_POD_coredns-66bff467f8-nhwkh_kube-system_7ab7cbd8-3062-4851-93d0-5d4e58491ec9_226
6231b6922d6f 4e9f801d2217 “/opt/bin/flanneld…” 23 hours ago Exited (255) 6 hours ago k8s_kube-flannel_kube-flannel-ds-amd64-2gfb2_kube-system_8758da21-9de1-4c14-a294-4820eb26773d_37
71ccf6966ce0 0d40868643c6 “/usr/local/bin/ku…” 23 hours ago Exited (255) 6 hours ago k8s_kube-proxy_kube-proxy-268rk_kube-system_fca74108-d0d2-43ff-b5f7-a59decabbf7a_24
1b8778773cd5| “/pause” 23 hours ago Exited (255) 6 hours ago k8s_POD_kube-flannel-ds-amd64-2gfb2_kube-system_8758da21-9de1-4c14-a294-4820eb26773d_24
a69a989b5397| “/pause” 23 hours ago Exited (255) 6 hours ago k8s_POD_kube-proxy-268rk_kube-system_fca74108-d0d2-43ff-b5f7-a59decabbf7a_24
ddaf6043ac38 6ed75ad404bd “kube-apiserver --…” 23 hours ago Exited (255) 6 hours ago k8s_kube-apiserver_kube-apiserver-kubemaster_kube-system_b7e2454e20d7d57ed4c269f01b412dbe_26
22560586ac00 303ce5db0e90 “etcd --advertise-…” 23 hours ago Exited (255) 6 hours ago k8s_etcd_etcd-kubemaster_kube-system_114a3b7d9915e80a91de886a97d78b39_25
8b4a5b1a8447| “/pause” 23 hours ago Exited (255) 6 hours ago k8s_POD_kube-scheduler-kubemaster_kube-system_155707e0c19147c8dc5e997f089c0ad1_24
b05f1c9a0331| “/pause” 23 hours ago Exited (255) 6 hours ago k8s_POD_etcd-kubemaster_kube-system_114a3b7d9915e80a91de886a97d78b39_24
89b1c267bfef| “/pause” 23 hours ago Exited (255) 6 hours ago k8s_POD_kube-apiserver-kubemaster_kube-system_b7e2454e20d7d57ed4c269f01b412dbe_24
726b5b21d8a7| “/pause” 23 hours ago Exited (255) 6 hours ago k8s_POD_kube-controller-manager-kubemaster_kube-system_7e7a524bbe609be08615d12902ca2d8c_24

Rahul Soni:
Yes thats correct, you can only see the control plane components under docker because they build the Kubernetes
You can only see the pod logs in different namespaces though.
Docker itself doesnt have a namespace because the container we create is isloted from other containers this is termed as namespace. Containers itself is made of linux premitives cgroups and namespaces, namespaces can also be of different types, network,uts,user, ipc etc etc

If you deploy Kubernetes as pods that you can see the docker images of control plane components else they will run as systemd service

Jason Snape:
Perfect, that is what I assumed from the output and makes total sense, thanks for the explanation.