Skip to content

Dockerfiles

VBrazhnik edited this page Jul 15, 2018 · 10 revisions

Exercise 00: vim/emacs

Exercise 00: vim/emacs
Turn-in directory : ex00/
Files to turn in : Dockerfile
Allowed functions : -
Notes : n/a

From an alpine image you’ll add to your container your favorite text editor, vim or emacs, that will launch along with your container.

Answer

FROM alpine

MAINTAINER vbrazhni <[email protected]>

RUN apk update && \
    apk upgrade && \
    apk add emacs

CMD emacs

Exercise 01: BYOTSS

Exercise 01: BYOTSS
Turn-in directory : ex01/
Files to turn in : Dockerfile + Scripts (if applicable)
Allowed functions : -
Notes : n/a

From a debian image you will add the appropriate sources to create a TeamSpeak server, that will launch along with your container. It will be deemed valid if at least one user can connect to it and engage in a normal discussion (no far-fetched setup), so be sure to create your Dockerfile with the right options. Your program should get the sources when it builds, they cannot be in your repository.

For the smarty-pants using the official docker image of TeamSpeak is strictly FORBIDDEN, and will get you -42.

Answer

FROM debian

MAINTAINER vbrazhni <[email protected]>

ENV TS3SERVER_LICENSE=accept

WORKDIR /home/teamspeak

EXPOSE 9987/udp 10011 30033

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y wget bzip2 && \
    wget http://dl.4players.de/ts/releases/3.0.13.4/teamspeak3-server_linux_amd64-3.0.13.4.tar.bz2 && \
    tar -jxvf teamspeak3-server_linux_amd64-3.0.13.4.tar.bz2

WORKDIR teamspeak3-server_linux_amd64

ENTRYPOINT ["sh", "ts3server_minimal_runscript.sh"]

Exercise 02: Dockerfile in a Dockerfile... in a Dockerfile ?

Exercise 02: Dockerfile in a Dockerfile... in a Dockerfile ?
Turn-in directory : ex02/
Files to turn in : Dockerfile
Allowed functions : -
Notes : n/a

You are going to create your first Dockerfile to containerize Rails applications. That’s a special configuration: this particular Dockerfile will be generic, and called in another Dockerfile, that will look something like this:

FROM ft-rails:on-build
EXPOSE 3000
CMD ["rails", "s", "-b", "0.0.0.0", "-p", "3000"]

Your generic container should install, via a ruby container, all the necessary dependencies and gems, then copy your rails application in the /opt/app folder of your container. Docker has to install the approtiate gems when it builds, but also launch the migrations and the db population for your application. The child Dockerfile should launch the rails server (see example below). If you don’t know what commands to use, it’s high time to look at the Ruby on Rails documentation.

Answer


Exercise 03: ... and bacon strips ... and bacon strips ...

Exercise 03: ... and bacon strips ... and bacon strips ...
Turn-in directory : ex03/
Files to turn in : Dockerfile
Allowed functions : -
Notes : n/a

Docker can be useful to test an application that’s still being developed without polluting your libraries. You will have to design a Dockerfile that gets the development version of Gitlab - Community Edition installs it with all the dependencies and the necessary configurations, and launches the application, all as it builds. The container will be deemed valid if you can access the web client, create users and interact via GIT with this container (HTTPS and SSH). Obviously, you are not allowed to use the official container from Gitlab, it would be a shame...

Clone this wiki locally