↓ Skip to main content
Containers

Dockerfile

·2 mins

docker build builds a docker image by reading instructions (directives) from a text file called Dockerfile

The build is run by the Docker daemon, not by the CLI

Hello World!
#

I would move in stages, like a good learning guide always recommends.

# Lesson 1 - Using basic Dockerfile to compose an image
FROM alpine:3.7 
# Using alpine 3.7 latest on the day.
CMD ["echo","Hello world!"]

The file above uses two directives and an image

Format: directive
#

Every directive you write in your docker file would follow a template

# INSTRUCTION arguments
FROM alpine:3.7

FROM directive identifies the parent image

alpine
#

This is a 5mb image small and convenient to get started in our case. You can find more details on how to use it here.

docker build -t samarthya/ahello:1.0 .
Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM alpine:3.7
 ---> 6d1ef012b567
Step 2/2 : CMD ["echo","Hello world!"]
 ---> Running in 4c96833eaeb6
Removing intermediate container 4c96833eaeb6
 ---> 460a990ca06c
Successfully built 460a990ca06c
Successfully tagged samarthya/ahello:1.0
docker image ls
REPOSITORY                           TAG                                              IMAGE ID            CREATED              SIZE
samarthya/ahello                     1.0                                              460a990ca06c        About a minute ago   4.21MB
docker image history 460a990ca06c
IMAGE               CREATED              CREATED BY                                      SIZE                COMMENT
460a990ca06c        About a minute ago   /bin/sh -c #(nop)  CMD ["echo" "Hello world!…   0B                  
6d1ef012b567        16 months ago        /bin/sh -c #(nop)  CMD ["/bin/sh"]              0B                  
<missing>           16 months ago        /bin/sh -c #(nop) ADD file:aa17928040e31624c…   4.21MB

A simple execution allows to see the desired output.

docker run --name hello samarthya/ahello:1.0
Hello world!

Reference
#

Author
Samarthya
Engineer, learner, tinkerer. This is my trophy shelf of everyday work and leisure.

Related

Docker

Usually I use Centos, but this time I wanted to try out docker swarm and ubuntu was the preferred option due to the options and supporting blogs available. Do read – https://docs.docker.com/get-started/#containers-and-virtual-machines docker.com

PV, PVC

·1 min
PV and PVC: PersistentVolume and PersistentVolumeClaim # PV - Defines the structure for provisioning storage for use. They have a defined lifecycle, independent of any individual Pod that uses the PV.

Elastic Alerting

Watcher # Watcher is an Elasticsearch feature that facilitates alerting and can be used to create actions based on conditions, which are periodically evaluated using queries on your data. There are two ways of creating a watcher