Note
As with my
first Docker course on Pluralsight, I wouldn't recommend
using LXC containers for working with Docker. Instead, running Ubuntu 20.04 VMs within VirtualBox should give you the perfect base environment for this course. I included a
video on working with VirtualBox in my Linux Server Virtualization course.
Contents:
A Simple Dockerfile
# Dockerfile contents:
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND="noninteractive" TZ="America/Toronto"
RUN apt-get update
RUN apt-get install -y apache2
ADD index.html /var/www/html/
CMD /usr/sbin/apache2ctl -D FOREGROUND
EXPOSE 80
Many Line Dockerfile
# dockerfile manyline:
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y curl
RUN mkdir -p /opt/jboss/wildfly
RUN cd /tmp
RUN curl -O https://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.tar.gz
RUN tar xf wildfly-10.1.0.Final.tar.gz
RUN mv wildfly-10.1.0.Final /opt/jboss/wildfly
RUN rm wildfly-10.1.0.Final.tar.gz
One Line Dockerfile
# dockerfile oneline:
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y curl
RUN mkdir -p /opt/jboss/wildfly && cd /tmp && \
curl -O https://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.tar.gz \
&& tar xf wildfly-10.1.0.Final.tar.gz \
&& mv wildfly-10.1.0.Final /opt/jboss/wildfly \
&& rm wildfly-10.1.0.Final.tar.gz
Launch Docker Registry With Persistent Storage
docker run -d \
-p 5000:5000 \
--restart always \
-v /var/images:/var/lib/registry \
registry:latest
Set Up User Authentication for a Docker Registry
docker run --entrypoint htpasswd \
registry:2.7.0 -Bbn dbclinton >> auth/htpasswd_file
docker run -d -p 5000:5000 \
--restart=no \
--name registry \
-v `pwd`/auth:/auth \
-e "REGISTRY_AUTH=htpasswd" \
-e "REGISTRY_AUTH_HTPASSWD_REALM=.basic-realm" \
-e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd_file" \
-v /certs:/certs \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
registry:2
webserver-config.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: webserver
spec:
replicas: 1
selector:
matchLabels:
app: webserver
template:
metadata:
labels:
app: webserver
spec:
containers:
- name: mywebserver
image: dbclinton/webserver:latest
imagePullSecrets:
- name: regcred-1