Introduction
Laymen explanation
If you have used docker container, you might be interested to know about docker container installation process. Simply consider that any product has installation guide (including consumer product like TV). Installation guide may be trivial (For example, TV installation) or have steps which need expert help (hosue electric wiring).
Similar situation arises with software installation. Installing firefox broswer is has trivial steps and hence they don't need a formal guide altogether. However, installing a LAMP software will require guide since it has non-trivial steps.
However, as a developer, you need to specify installation instruction for firefox as well which we can call as configuration step. This configuration file will be executed at the user end.
So, for developer, every time instructing computer for configuration is a non-trivial operation. Similar is the case for Docker installation. This document tries to help in this regard.
Technical explanation
Docker container image can be built in multiple ways. Once successfully built, an image will be installed and it can be viewed using 'docker images' command.
Build image using local configuration file
Example of docker build using local file
sudo docker build --force-rm=true --no-cache=true --rm=true -t test:21.1 .
This command will execute Dockerfile (in the same directory path).
Intermediate containers will always be removed
This will create image with name test:21.1
Dockerfile
About
Dockerfile command
Building using URL
In this case, docker uses Dockerfile provided in the link.
Example for building using URL
[root@ubuntu /personal/nstrace/temp]# docker build github.com/creack/docker-firefox
Sending build context to Docker daemon 56.83 kB
Step 1 : FROM ubuntu:12.04
12.04: Pulling from library/ubuntu
27bc2519292c: Pull complete
7519d1c0da9d: Pull complete
8e7b1958fef8: Pull complete
ca73fb388417: Pull complete
21de44fd704b: Pull complete
Digest: sha256:65e7041a861f38f71859da0c51bd0925f34b66d2ee0dbd882c9f4bb1ae0424a8
Status: Downloaded newer image for ubuntu:12.04
---> c669f0ad611f
Step 2 : RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
---> Running in 4a1011aaa198
---> 3487b44a22c5
Removing intermediate container 4a1011aaa198
Step 3 : RUN apt-get update
---> Running in f62c3234dcb9
Get:1 http://archive.ubuntu.com precise Release.gpg [198 B]
Get:2 http://archive.ubuntu.com precise Release [49.6 kB]
Get:3 http://archive.ubuntu.com precise/main amd64 Packages [1640 kB]
Get:4 http://archive.ubuntu.com precise/universe amd64 Packages [6167 kB]
Get:5 http://archive.ubuntu.com precise/main i386 Packages [1641 kB]
Get:6 http://archive.ubuntu.com precise/universe i386 Packages [6180 kB]
Fetched 15.7 MB in 26s (599 kB/s)
Reading package lists...
---> a66206a7dc3a
Removing intermediate container f62c3234dcb9
Step 4 : RUN apt-get install -y x11vnc xvfb firefox
---> Running in 8d052ba1b037
........................
......................
Here, the link github.com/creack/docker-firefox has Dockefile which is read and executed by docker build command.
In detail, this will clone the GitHub repository and use the cloned repository as context. The Dockerfile at the root of the repository is used as Dockerfile.
Reference
https://docs.docker.com/engine/reference/commandline/build/
http://odewahn.github.io/docker-jumpstart/building-images-with-dockerfiles.html
https://docs.docker.com/engine/reference/builder/