How to create a custom docker conainer

Container May 25, 2021

You will get several docker images, but you will not get all what you want. For my case I must create a custom docker container for my iobroker (opens new window)instance. Because I want to host a live stream on youtube with iobroker, but there was no ffmpeg installed in this container. This was OK for the maintainer but not for me 😃

Docker Commands

So, before we start creating our Dockerfile, we need to learn the necessary commands to create a working Dockerfile. There are dozens of commands that can be used to create it but we'll quick learn about those commands.


Add command is used to copy the files from a source directory to destination, the source can also be an url. If its an url, the command will simply download the target to the destination directory.


CMD command is used to execute specific commands that gets executed with the creation of containers based on the image. It is very similar to RUN command whereas CMD is not executed during build.


ENTRYPOINT argument sets the concrete default application that is used every time a container is created using the image.


ENV is used to set the environment variables. These variables can be accessed with the docker container which offers an enormous amount of flexibility for running programs..


FROM argument defines the base image to use to start the build process which can be any docker image whether its on the host or in the repository.


The WORKDIR directive is used to set where the command defined with CMD is to be executed.


RUN is the command which is used to build the docker images which is a centrally executing directive for the Dockerfiles.


MAINTAINER is the command which doesn't get executed but declares the author, hence setting the author field of the images.


The USER directive is used to set the UID (or username) which is to run the container based on the image being built.


The VOLUME command is used to enable access from your container to a directory on the host machine.


The EXPOSE command is used to associate a specified port to enable networking between the running process inside the container and the host.

Create a docker file

Instead of building iobroker from ground zero, I will resuse the dockerfile from the maintainer.

# Pull the base image
FROM  'buanet/iobroker:latest'
# Update Apt-egt sources and install Requirements
RUN apt-get update ; apt-get install -y git build-essential gcc make yasm autoconf automake cmake libtool checkinstall libmp3lame-dev pkg-config l$

# Not install common requirements for the installation of ffmpeg 
RUN apt-get update \
    && apt-get clean \
    && apt-get install -y --no-install-recommends libc6-dev libgdiplus wget software-properties-common

# Fetch ffmpeg and extract
RUN wget
RUN tar -xzf ffmpeg-4.0.2.tar.gz; rm -r ffmpeg-4.0.2.tar.gz

# Configure and compile it
RUN cd ./ffmpeg-4.0.2; ./configure --enable-gpl --enable-libmp3lame --enable-decoder=mjpeg,png --enable-encoder=png --enable-openssl --enable-nonf$
RUN cd ./ffmpeg-4.0.2; make

# No install ffmpeg in the bin dir
RUN  cd ./ffmpeg-4.0.2; make install

# After all, every docker image gets an update of ionbroker
RUN iobroker update
RUN iobroker upgrade self

Building the Dockercontainer

Now we setup the commands to create a custom image. For this you mus only enter this command

$ sudo docker build -t iobroker:customffmpeg .

Now you will se a output like this:

Running the created container

After you created the container. You are ready to run it for the first time.

$ docker run --name myiobrokerinstance iobroker:customffmpeg 

And there you have it, your own customized container 😃


On the internet there exists many container for every need, but not for you. You learned in this blog how you can create a custom container, the exactly match you need.

I hope you will like this post and take it as a small tutorial for you 😃

If you have any suggestions, please leave me a comment.