Dockerfile#
FROM fedora:30
RUN dnf -y update && dnf clean all
RUN dnf -y install systemd && dnf clean all && \
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup", "/tmp", "/run" ]
CMD ["/usr/sbin/init"]
Building Fedora Container Image#
$ docker build -t fedora .
Pushing Fedora Container Image#
$ docker tag fedora:latest <username>/fedora:latest
$ docker push <username>/fedora:latest
Available Images#
Creating Fedora Image Stream#
Prepare a configuration file (e.g. fedora-is.yaml):
apiVersion: v1
kind: ImageStream
metadata:
labels:
app: fedora
name: fedora
spec:
tags:
- from:
kind: DockerImage
name: edewata/fedora
name: latest
Then execute the following command:
$ oc create -f fedora-is.yaml
Creating Fedora Application#
Prepare a configuration file (e.g. fedora-dc.yaml):
apiVersion: v1
kind: DeploymentConfig
metadata:
labels:
app: fedora
name: fedora
spec:
selector:
app: fedora
deploymentconfig: fedora
template:
metadata:
labels:
app: fedora
deploymentconfig: fedora
spec:
containers:
- image: edewata/fedora
name: fedora
volumeMounts:
- mountPath: /run
name: fedora-volume-1
- mountPath: /sys/fs/cgroup
name: fedora-volume-2
- mountPath: /tmp
name: fedora-volume-3
volumes:
- emptyDir: {}
name: fedora-volume-1
- emptyDir: {}
name: fedora-volume-2
- emptyDir: {}
name: fedora-volume-3
test: false
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- fedora
from:
kind: ImageStreamTag
name: 'fedora:latest'
type: ImageChange
Then execute the following command:
$ oc create -f fedora-dc.yaml
Starting Fedora Application#
$ oc scale dc fedora --replicas=1
Updating Container Image#
If newer container image is available, it can be deployed with the following command:
$ oc import-image <username>/fedora:latest