Personal Programming Notes

To err is human; to debug, divine.

Docker-in-Docker vs Docker-out-of-Docker

In this post, we look into two different approaches to solving the problem of building/pushing Docker images from a containerized Jenkins system. From that understanding, we will discuss the pros and cons of each approach in production Continuous Integration (CI) systems and how one should be used in practice.

Load Groovy Script in Jenkins Pipeline

In this post, we look into loading and reusing independent Groovy scripts for more modular and testable Jenkins pipeline. An example with Scripted Pipeline is provided although it is also applicable to newer Declarative Pipeline with minor modifications. Keep in mind that Jenkins Shared Libraries is the more scalable alternative to run and reuse custom Groovy scripts in Jenkins pipeline.

Docker: Files Not Found in Docker Container

In this post, we look into a perplexing issue that happens often when we try to extend an offical image. In summary, there is currently no way to add additional content into VOLUME directory in a trivial way. If you unknowingly adds files into a folder that has been used as a VOLUME mount point in a Docker image or one of its base images, the files cannot be found for seemingly no reason.

Docker: Root User in a Pod

In the following scenario, we have some pod running in Kubernetes cluster.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
tdongsi-mac:kubernetes tdongsi$ kubectl --kubeconfig kubeconfig describe pod jenkins
Name:             jenkins
Namespace:            default
Image(s):         docker.registry.company.net/tdongsi/jenkins:2.23
Node:             kube-worker-1/10.252.158.72
Start Time:           Tue, 24 Jan 2017 16:57:47 -0800
Labels:               name=jenkins
Status:               Running
Reason:
Message:
IP:               172.17.27.3
Replication Controllers:  <none>
Containers:
  jenkins:
    Container ID: docker://943d6e55038804c8
    Image:        docker.registry.company.net/tdongsi/jenkins:2.23
    Image ID:     docker://242c1836544e5ca31616
    State:        Running
      Started:        Tue, 24 Jan 2017 16:57:48 -0800
    Ready:        True
    Restart Count:    0
    Environment Variables:
Conditions:
  Type        Status
  Ready   True
Volumes:
  jenkins-data:
    Type: HostPath (bare host directory volume)
    Path: /jdata
No events. 

For troubleshooting purposes, we sometimes need to enter the container or execute some commands with root privilege. Sometimes, we simply cannot sudo or have the root password.

Automated Downloading BART Parking Permits

Problem

I have been commuting to San Francisco using BART. For BART commutes, before having the Monthly Parking Permit, you usually have no choice but using Daily Parking Permits for car parking. You will often end up having to download multiple PDF files for the daily permits and print them to put on your vehicle’s dashboard. The BART reservation website offers no easy way to download all of them in one click (see the screenshot).

BART Screenshot

Personally, the BART commute itself is not that bad, especially when I usually find a seat. But it is really painful to download every … single … PDF … permit manually before printing them.