Docker – ubuntu

Docker

ubuntu only

jjest@donkey:~$ sudo snap install docker
docker 18.06.1-ce from Canonical✓ installed

search for pre-built images

jjest@donkey:~$ sudo docker search mariadb
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mariadb MariaDB is a community-developed fork of MyS… 3049 [OK]

get image

jjest@donkey:~$ sudo docker pull mysql
Using default tag: latest
latest: Pulling from library/mariadb
22e816666fd6: Pull complete
079b6d2a1e53: Pull complete
11048ebae908: Pull complete
c58094023a2e: Pull complete
1e8f13102fa0: Pull complete

Status: Downloaded newer image for mariadb:latest

jjest@donkey:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mariadb latest a9e108e8ee8a 7 days ago 356MB

Save an image w/ modifications

jjest@donkey:~$ sudo docker save ubuntu > ubuntu-rev.tar

jjest@donkey:~$ sudo docker import ubuntu-rev1.tar
sha256:252ee581e4c37dc130f62650c7d8cb7dc5e316b82c74d9b573a9b4b4a35bf4d6

jjest@donkey:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> 252ee581e4c3 12 seconds ago 66.6MB
mariadb latest a9e108e8ee8a 7 days ago 356MB
ubuntu latest cf0f3ca922e0 7 days ago 64.2MB
mysql latest c8ee894bd2bd 8 days ago 456MB

jjest@donkey:~$ sudo docker tag 252ee581e4c3 ubuntu:rev1

jjest@donkey:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu rev1 252ee581e4c3 4 minutes ago 66.6MB
mariadb latest a9e108e8ee8a 7 days ago 356MB
ubuntu latest cf0f3ca922e0 7 days ago 64.2MB
mysql latest c8ee894bd2bd 8 days ago 456MB

create container

jest@donkey:~$ sudo docker create ubuntu
2ba60346ba6a643bb8b1d4dc510ac119590a4596ef5f5e254ff5c2c07f45e82a
jjest@donkey:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2ba60346ba6a ubuntu “/bin/bash” 2 seconds ago Created frosty_aryabhata
186da96f2df2 ubuntu “/bin/bash” About a minute ago Created pedantic_brahmagupta
52f9d832fd0f ubuntu “/bin/bash” About an hour ago Exited (0) About an hour ago vibrant_bohr
80f26b4938df mysql “docker-entrypoint.s…” About an hour ago Exited (1) About an hour ago adoring_perlman
e4ce7ab183c5 mysql “docker-entrypoint.s…” About an hour ago Exited (1) About an hour ago eager_heyrovsky
40ecb1787e8d mysql “docker-entrypoint.s…” About an hour ago Exited (1) About an hour ago determined_mcnulty
….

jjest@donkey:~$ sudo docker ps -a -f status=running
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b755d3157f4b mysql “docker-entrypoint.s…” 2 hours ago Up 2 hours 3306/tcp, 33060/tcp mariadb

jjest@donkey:~$ sudo docker history mysql
IMAGE CREATED CREATED BY SIZE COMMENT
c8ee894bd2bd 8 days ago /bin/sh -c #(nop) CMD [“mysqld”] 0B
8 days ago /bin/sh -c #(nop) EXPOSE 3306 33060 0B
8 days ago /bin/sh -c #(nop) ENTRYPOINT [“docker-entry… 0B
8 days ago /bin/sh -c ln -s usr/local/bin/docker-entryp… 34B
8 days ago /bin/sh -c #(nop) COPY file:b3081195cff78c47… 12.7kB
….

Starting/Stopping containers

jjest@donkey:~$ sudo docker start b755d3157f4b
b755d3157f4b
jjest@donkey:~$ sudo docker container list
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b755d3157f4b mysql “docker-entrypoint.s…” 2 hours ago Up 3 seconds 3306/tcp, 33060/tcp mariadb
jjest@donkey:~$ sudo docker stop b755d3157f4b
b755d3157f4b
jjest@donkey:~$ sudo docker container list
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

Kubernetes (microk8 – single node) https://microk8s.io/
tutorial: https://tutorials.ubuntu.com/tutorial/install-a-local-kubernetes-with-microk8s#0

jjest@donkey:~$ sudo snap install microk8s –classic
microk8s v1.16.2 from Canonical✓ installed

jjest@donkey:~$ sudo microk8s.status
microk8s is running
addons:
cilium: disabled
dashboard: disabled
dns: disabled
fluentd: disabled
gpu: disabled
helm: disabled
ingress: disabled
istio: disabled
jaeger: disabled
knative: disabled
linkerd: disabled
metrics-server: disabled
prometheus: disabled
rbac: disabled
registry: disabled
storage: disabled

jjest@donkey:~$ sudo microk8s.kubectl get nodes
NAME STATUS ROLES AGE VERSION
donkey Ready 2m39s v1.16.2

Always enable

jjest@donkey:~$ sudo microk8s.enable dashboard dns
Applying manifest
serviceaccount/kubernetes-dashboard created
service/kubernetes-dashboard created
secret/kubernetes-dashboard-certs created
secret/kubernetes-dashboard-csrf created
secret/kubernetes-dashboard-key-holder created
configmap/kubernetes-dashboard-settings created
role.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
deployment.apps/dashboard-metrics-scraper created
service/monitoring-grafana created
service/monitoring-influxdb created
service/heapster created
deployment.apps/monitoring-influxdb-grafana-v4 created
serviceaccount/heapster created
clusterrolebinding.rbac.authorization.k8s.io/heapster created
configmap/heapster-config created
configmap/eventer-config created
deployment.apps/heapster-v1.5.2 created

If RBAC is not enabled access the dashboard using the default token retrieved with:

token=$(microk8s.kubectl -n kube-system get secret | grep default-token | cut -d ” ” -f1)
microk8s.kubectl -n kube-system describe secret $token

In an RBAC enabled setup (microk8s.enable RBAC) you need to create a user with restricted
permissions as shown in:
https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md

Enabling DNS
Applying manifest
serviceaccount/coredns created
configmap/coredns created
deployment.apps/coredns created
service/kube-dns created
clusterrole.rbac.authorization.k8s.io/coredns created
clusterrolebinding.rbac.authorization.k8s.io/coredns created
Restarting kubelet
DNS is enabled

jjest@donkey:~$ sudo microk8s.kubectl get all –all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system pod/coredns-9b8997588-6q722 1/1 Running 1 85s
kube-system pod/dashboard-metrics-scraper-566cddb686-x8hlv 1/1 Running 0 87s
kube-system pod/heapster-v1.5.2-5c58f64f8b-xj4z2 4/4 Running 2 86s
kube-system pod/kubernetes-dashboard-678b7d865c-2bhvx 1/1 Running 0 87s
kube-system pod/monitoring-influxdb-grafana-v4-6d599df6bf-mdqqv 2/2 Running 1 87s

NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default service/kubernetes ClusterIP 10.152.183.1 443/TCP 8m39s
kube-system service/dashboard-metrics-scraper ClusterIP 10.152.183.46 8000/TCP 87s
kube-system service/heapster ClusterIP 10.152.183.27 80/TCP 87s
kube-system service/kube-dns ClusterIP 10.152.183.10 53/UDP,53/TCP,9153/TCP 85s
kube-system service/kubernetes-dashboard ClusterIP 10.152.183.113 443/TCP 87s
kube-system service/monitoring-grafana ClusterIP 10.152.183.129 80/TCP 87s
kube-system service/monitoring-influxdb ClusterIP 10.152.183.159 8083/TCP,8086/TCP 87s

NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
kube-system deployment.apps/coredns 1/1 1 1 85s
kube-system deployment.apps/dashboard-metrics-scraper 1/1 1 1 87s
kube-system deployment.apps/heapster-v1.5.2 1/1 1 1 86s
kube-system deployment.apps/kubernetes-dashboard 1/1 1 1 87s
kube-system deployment.apps/monitoring-influxdb-grafana-v4 1/1 1 1 87s

NAMESPACE NAME DESIRED CURRENT READY AGE
kube-system replicaset.apps/coredns-9b8997588 1 1 1 85s
kube-system replicaset.apps/dashboard-metrics-scraper-566cddb686 1 1 1 87s
kube-system replicaset.apps/heapster-v1.5.2-5c58f64f8b 1 1 1 86s
kube-system replicaset.apps/kubernetes-dashboard-678b7d865c 1 1 1 87s
kube-system replicaset.apps/monitoring-influxdb-grafana-v4-6d599df6bf 1 1 1 87s

https://docs.docker.com/engine/reference/commandline/save/