Skip to content

Instantly share code, notes, and snippets.

@osowski
Forked from csantanapr/Dockerfile
Last active July 24, 2020 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osowski/4c9b6eb8e63b93e97ad6fecd8d9c8ff4 to your computer and use it in GitHub Desktop.
Save osowski/4c9b6eb8e63b93e97ad6fecd8d9c8ff4 to your computer and use it in GitHub Desktop.
dind on Kubernetes

Instructions

  • Run oc apply -f dind.yaml to deploy a Docker-in-Docker pod.
  • Run oc exec -it dind bash to connect to the pod.
  • Run docker pull hello-world to validate the environment.
  • If you get a timeout failure when pulling the issue, update /etc/resolv.conf inside the running dind container instance to set the primary nameserver:
search [existing-cluster-specific-search-domains]
nameserver 8.8.8.8
nameserver [existing-cluster-specific-nameserver]
options ndots 5

Troubleshooting

  • In my experience, it can be temperamental to connect to the pod if it lands on specific Nodes for some unknown reason. If this occurs (timing out during the initial oc exec -it dind bash), delete the pod and recreate it to place it on another Node.
apiVersion: v1
kind: Pod
metadata:
name: dind
labels:
app: dind
spec:
volumes:
- name: dind-storage
emptyDir: {}
- name: workspace
emptyDir: {}
containers:
- name: dind
image: ibmcase/docker:dind
imagePullPolicy: Always
securityContext:
privileged: true
volumeMounts:
- name: dind-storage
mountPath: /var/lib/docker
- name: workspace
mountPath: /root/workspace
FROM docker:dind
RUN set -eux; \
apk add --no-cache \
git \
iptables \
jq \
bash \
vim \
curl \
nano \
maven
ENV IBMCLOUD_CLI_VERSION 1.1.0
ADD https://clis.cloud.ibm.com/download/bluemix-cli/${IBMCLOUD_CLI_VERSION}/linux64/archive /ibmcloud.tgz
RUN set -eux; \
tar -xvf /ibmcloud.tgz -C /usr/local/bin/ --strip-components=1 && \
ibmcloud config --usage-stats-collect false && \
ibmcloud plugin repo-plugins -r 'IBM Cloud' && \
ibmcloud plugin install kubernetes-service && \
ibmcloud plugin install container-registry
WORKDIR /root/workspace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment