How to Automatically Build and Configure Custom Docker Images with Dockerfile – Part 3

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Matei Cezar

I'am a computer addicted guy, a fan of open source and linux based system software, have about 4 years experience with Linux distributions desktop, servers and bash scripting.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

5 Responses

  1. Paul says:

    Thank you for this hands-on Docker tutorial. Worked fine.

    In the Dockerfile, had to replace one line with this to avoid a error finding apache2:

    # apt-get update && apt-get -y install apache2
  2. Alan says:

    Help, years old instructions..

    So, i have to hand write a dockerfile, and know what the variables are. So lets just say i followed section 3, the Apache setup, less the mounting external file inside the container, went to follow the instructions to contain it and pump it to AWS/docker service so i need to:

    “”docker build -t test .” and i get:

    “unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /var/lib/docker/Dockerfile: no such file or directory”

    You have a “The following instructions are the most used, some of them being mandatory:”

    so: “FROM” is that the base OS? or the encapsulated OS?, and what is it referencing that from since its “Mandatory” i cant just do a “ASDF”? doing a little looking, that’s the container’s OS variant.. so “FROM httpd:2.4” ?

    • “MAINTAINER” is that me? or the AWS user? the OS user? what? not mandatory?
    • “RUN” im guessing thats the commands for the container OS?
    • “CMD” whats this then for? i thought i did that with RUN
    • “ENTRYPOINT” “same as CMD” so i run command thrice?
    • “EXPOSE” is this the same as -P argument? or different string? I don’t know..
    • “ENV” environment variables, any information on that? what are the things I can variate? all I know is “HOME /root”
    • “ADD” so i guess this is null’n’void to me, since CP’ing the files into the container, since I need it self contained..

    Can I add “CMD docker cp /media/home/me/Desktop/files.php Container:/var/www/html” ?

    Will that pull files from my desktop when “docker build” command runs? or do i have to get a container running then do that manually?

    So I am some what surprised this isn’t populated in a file when you get a docker container to run, you’d think it’ll be part of the docker creation process, base stats with the variables, all the other lovely files are created, why not the basic dockerfile? why does it have to be hand written? so many mistakes can be made like that..

    and someone explain to me why docker containers have a underline OS? i thought this system used the base OS and plug dependencies though a “firewall” like feature.

    Seems like its: BaseOS -> Docker -> Container OS -> Application

    looks a lot like a VM process: BaseOS -> VME -> VMOS -> Application

  3. Kiran Vara Prasad says:

    Thank you for the great article Matei Cezar

  4. vignesh.s says:

    Can you please share the docker image script of centos image?

Got something to say? Join the discussion.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.