Docker_Image_Build_Docker-file

Docker_Image_Build_Docker-file

Docker File

Docker builds images automatically by reading the instructions from a Dockerfile — a text file that contains all commands, in order, needed to build a given image

In this example, I am going to setup the WordPress site(Only Application) with the Ubuntu image. these are required packages.

  1. Apache
  2. PHP
  3. WordPress file

First, create "dockerfile" with all requirement.


[root@rhel7 docker]# cat dockerfile
FROM ubuntu:latest
LABEL maintainer="bibhutimail@gmail.com"
RUN export https_proxy="http://XXX.XX.XX.XX:8080"
RUN export http_proxy="http://XXX.XX.XX.XX:8080"
RUN apt-get update && apt install -y apache2 && apt install -y php && apt install -y libapache2-mod-php && apt install -y php-mysql && apt install -y php-pear && apt install -y php-fpm

Now build new docker image with help of "dockerfile.

[root@rhel7 docker]# docker build -t feenixdv/feenixdv_web:1.0 .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM ubuntu:latest
 —> 93fd78260bd1
Step 2 : LABEL maintainer "bibhutimail@gmail.com"
 —> Using cache
 —> 97d02e86f7e0
.
.
.
.
debconf: falling back to frontend: Readline
Configuring tzdata
——————

Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.

  1. Africa      4. Australia  7. Atlantic  10. Pacific  13. Etc
  2. America     5. Arctic     8. Europe    11. SystemV
  3. Antarctica  6. Asia       9. Indian    12. US
Geographic area: 9

Terminal stop/hang on this section "please select the geographic area in which you live docker"
Update Dockerfile.

[root@rhel7 docker]# cat dockerfile
FROM ubuntu:latest
LABEL maintainer="bibhutimail@gmail.com"
RUN export https_proxy="http://XXX.XX.XX.XX:8080"
RUN export http_proxy="http://XXX.XX.XX.XX:8080"
RUN apt-get update
RUN apt-get install -y tzdata
#ENV TZ Asia/india
RUN apt install -y apache2 && apt install -y php && apt install -y libapache2-mod-php && apt install -y php-mysql && apt install -y php-pear && apt install -y php-fpm

[root@rhel7 docker]# docker build -t feenixdv/feenixdv_web:1.0 .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM ubuntu:latest
 —> 93fd78260bd1
Step 2 : LABEL maintainer "bibhutimail@gmail.com"
 —> Using cache
 —> 97d02e86f7e0
.
.
.
php_invoke: Enabled module pdo_mysql for fpm sapi
php_invoke: Enabled module dom for fpm sapi
php_invoke: Enabled module simplexml for fpm sapi
php_invoke: Enabled module wddx for fpm sapi
php_invoke: Enabled module xml for fpm sapi
php_invoke: Enabled module xmlreader for fpm sapi
php_invoke: Enabled module xmlwriter for fpm sapi
php_invoke: Enabled module xsl for fpm sapi
NOTICE: Not enabling PHP 7.2 FPM by default.
NOTICE: To enable PHP 7.2 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.2-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
invoke-rc.d: could not determine current run level
invoke-rc.d: policy-rc.d denied execution of start.
Setting up php-fpm (1:7.2+60ubuntu1) …
Processing triggers for libc-bin (2.27-3ubuntu1) …
 —> 05b5fd5f944a
Removing intermediate container e5ed499128f0
Successfully built 05b5fd5f944a

Now we can see our Docker image created with all prerequisites(Apache, PHP..).


[root@rhel7 yum.repos.d]# docker images
REPOSITORY                              TAG                 IMAGE ID            CREATED             SIZE
feenixdv/feenixdv_web                   1.0                 633bd89f2cb6        5 hours ago         300 MB

 

Leave a Reply

Your email address will not be published. Required fields are marked *