Maybe a lot of you have already heard and maybe even mastered Docker. This is my first docker image and I’ll like to share some basic concepts I have learned from it.
I will also appreciate any comment to improve this image.
So, what is Docker?
Wikipedia: “Docker is an open-source project that automates the deployment of applications inside software containers, by providing an additional layer of abstraction and automation of operating-system-level virtualization on Linux”
I see it like a nice way to automate tasks (avoid repeating the same task over and over) and making a container of it, allowing me to use it “where ever” I want.
Basic Docker Operations:
Build
docker build -t [username]/[imagename] [Dockerfile path]
docker build -t mfh/webtier /home/docker/webtier/.
This will use a Dockerfile stored in “/home/docker/webtier/” to create an image called “mfh/WebTier”.
Run
docker run [arguments] [image]
docker run -p 80:80 mfh/webtier
docker run -it mfh/webtier /bin/bash
docker run -d -p 80:80 mfh/webtier
ps
docker ps
This will display the docker containers currently running and its name and id.
Exec
docker exec [running container id]
docker exec -it c357930de48c /bin/bash
This will allow you to look into a running container.
My Scenario:
We constantly have clients using a front end server to receive all the incoming requests and then send it to the final destination. In terms of Oracle this will mean, Apache Web Server with mod_wl.so redirecting to WebLogic ( More than half of the clients use OHS).
Hands On!
- Create a Dockerfile
- Download and / or create external files.
- Build Dockerfile
- Run the Docker container
Dockerfile
This file was based on appcontainers/apache.
FROM centos:centos7 MAINTAINER mauro.flores.g@gmail.com ENV APP_NAME apache.local ENV APACHE_LOG_DIR /var/log/httpd # Clean, Update, and Install... then clear non English local data. RUN yum clean all && \ yum -y update && \ # Install required packages yum -y install httpd24.x86_64 mod_rewrite mod_ssl mod_env && \ # Remove yum cache this bad boy can be 150MBish yum clean all && \ rm -fr /var/cache/* # Remove locales other than english RUN for x in `ls /usr/share/locale | grep -v -i en | grep -v -i local`;do rm -fr /usr/share/locale/$x; done && \ for x in `ls /usr/share/i18n/locales/ | grep -v en_`; do rm -fr /usr/share/i18n/locales/$x; done && \ rm -fr ca* den men wen zen && \ cd /usr/lib/locale && \ localedef --list-archive | grep -v -i ^en | xargs localedef --delete-from-archive && \ mv -f locale-archive locale-archive.tmpl && \ build-locale-archive ADD apache-config.conf /etc/httpd/conf.d/ # Copy site CMD ["mkdir", "/var/www/html"] ADD site /var/www/html/ # Expose ports EXPOSE 80 EXPOSE 443 #Copy Apache HTTP Server Plug-In COPY ./mod_wl/lib/*.so /usr/lib64/httpd/modules/ COPY mod_wl.conf /etc/httpd/conf.d/ COPY mod_wl.load.conf /etc/httpd/conf.modules.d/ #Create Volume VOLUME ["/var/www/html", "/var/log/httpd"] # Start apache. CMD /usr/sbin/httpd -D FOREGROUND
To run the container:
docker run -d -p 80:80 -v ~/docker/webtier/html:/var/ww/html webtier
More information regarding Docker: