Welcome to the Linux Foundation Forum!

Chapter 8: Dockerfile for Jenkins /w Docker image

After you install docker into Jenkins, shutdown for the night, and... reinstall docker the next day?

Don't Repeat Yourself!

You probably have enough experience by now to create your own Jenkins /w Docker image, but I thought some people might benefit from an example Dockerfile.
It's all very straight forward if you are familiar with sed and running Ubuntu. Perhaps you may need to change the group id for another system.

FROM jenkins/jenkins:slim 
# valid as of Sept. 14 2020

USER root

RUN apt-get update && \
    apt-get -yqq install apt-transport-https ca-certificates curl gnupg-agent software-properties-common && \
    curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - && \
    apt-key fingerprint 0EBFCD88  && \
    add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \
    apt-get update && \
    apt-get -yqq install docker-ce docker-ce-cli containerd.io && \
    apt-cache madison docker-ce && \
    apt-get -yqq install docker-ce docker-ce-cli containerd.io && \
    usermod -aG docker jenkins && \
    sed -i 's/999/1001/' /etc/group

EXPOSE 8080

If you know of a way to improve on this to make a smaller image I'd be interested to know how!

Comments

  • Note the typo:
    duplicated apt-get

    apt-get -yqq install docker-ce docker-ce-cli containerd.io && \

  • @danielclough thank you for this. A note to add though is you need not install docker if you just stop the container and start it again. Its needed only if you destroy and start.

Categories

Upcoming Training