Browse Source

Initial import

Suren A. Chilingaryan 6 years ago
commit
a4f8f68f26
4 changed files with 163 additions and 0 deletions
  1. 30 0
      Dockerfile
  2. 38 0
      Makefile
  3. 70 0
      README.md
  4. 25 0
      sx.sh

+ 30 - 0
Dockerfile

@@ -0,0 +1,30 @@
+FROM centos:centos7
+MAINTAINER Suren A. Chilingaryan
+
+ENV container centos-tools
+ 
+RUN [ -e /etc/yum.conf ] && sed -i '/tsflags=nodocs/d' /etc/yum.conf || true
+
+# Reinstall all packages to get man pages for them
+RUN yum -y reinstall "*" && yum clean all
+
+# Swap out the systemd-container package and install all useful packages
+RUN yum -y install \
+           yum-utils glibc-utils bash-completion less file sed findutils net-tools man-db which bc tar \
+           openssh-clients lftp curl samba-client \
+           screen vim-enhanced nano \
+           git bzr \
+           mc \
+           kubernetes-client \
+           && yum clean all
+
+# Set default command
+CMD ["/usr/bin/bash"]
+
+
+
+COPY sx.sh /bin/sx
+RUN chmod 775 /bin/sx
+
+CMD [ "/bin/sx" ]
+

+ 38 - 0
Makefile

@@ -0,0 +1,38 @@
+all: build
+install: push
+
+.PHONY: rebuild build push start stop restart bash
+
+build: Dockerfile
+	docker build --tag chsa/centos-tools:latest .
+
+rebuild: Dockerfile
+	docker build --no-cache --tag chsa/centos-tools:latest .
+
+push: build
+	docker push chsa/centos-tools:latest
+
+start: build
+	if [ `docker ps | grep chsa/centos-tools | wc -l` -eq 0 ]; then \
+	    if [ `docker ps -a | grep centos-tools | wc -l` -gt 0 ]; then \
+		echo "Removing the stalled copy..." ;\
+		docker stop centos-tools ;\
+		docker rm centos-tools ;\
+	    fi ;\
+	    docker run --name centos-tools -t -d chsa/centos-tools:latest ;\
+	else \
+	    echo "Already running..." ;\
+	fi
+
+stop:
+	@if [ `docker ps | grep centos-tools | wc -l` -gt 0 ]; then \
+	    docker stop centos-tools ;\
+	    docker rm centos-tools ;\
+	fi
+
+restart:
+	make stop
+	make start
+
+bash: build
+	docker exec -it centos-tools /bin/bash

+ 70 - 0
README.md

@@ -0,0 +1,70 @@
+# Docker OS Images : Centos7
+
+Simple container used to have an os container running in openshift and ready to investigate using sysadmin tools. This image is based on [centos/s2i-core-centos7](https://hub.docker.com/r/centos/s2i-core-centos7) done by [sclorg](https://github.com/sclorg/s2i-base-container/tree/master/core).
+
+You can find information on this image and how to use it by visiting the [Dockerhub registry](https://github.com/startxfr/docker-images)
+
+This container contain updated core OS rpm (kernel, libs,...) as well as usefull tools like pwgen, tar, zip, psmisc, procps, coreutils, findutils, wget
+
+| [![Build Status](https://travis-ci.org/startxfr/docker-images.svg?branch=openshift)](https://travis-ci.org/startxfr/docker-images) | [Dockerhub Registry](https://hub.docker.com/r/startx/openshift-centos) | [Sources](https://github.com/startxfr/docker-images/OS/)             | [STARTX Profile](https://github.com/startxfr) | 
+|-------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|----------------------------------------------------------------------|-----------------------------------------------|
+
+## Running from dockerhub registry
+
+* with `docker` you can run `docker run -it --name="centos" startx/openshift-centos` from any docker host
+* with `docker-compose` you can create a docker-compose.yml file with the following content
+```
+fedora:
+  image: startx/openshift-centos:latest
+  container_name: "os-ocp-centos7"
+  environment:
+    CONTAINER_TYPE: "os"
+    CONTAINER_SERVICE: "fedora"
+    CONTAINER_INSTANCE: "os-ocp-centos7"
+```
+
+## Using this image in your own container
+
+You can use this Dockerfile template to start a new personalized container based on this container
+ ```
+FROM startx/openshift-centos:latest
+#... your container specifications
+CMD ["/bin/sx"]
+```
+
+## Environment variable
+
+| Variable                  | Type     | Mandatory | Description                                                              |
+|---------------------------|----------|-----------|--------------------------------------------------------------------------|
+| CONTAINER_INSTANCE        | `string` | `yes`     | Container name. Should be uning to get fine grained log and application reporting
+| CONTAINER_TYPE            | `string` | `no`      | Container family (os, service, application. could be enhanced 
+| CONTAINER_SERVICE         | `string` | `no`      | Define the type of service or application provided
+| HOSTNAME                  | `auto`   | `auto`    | Container unique id automatically assigned by docker daemon at startup
+
+
+## For advanced users
+
+You you want to use this container and code to build and create locally this container. You can follow theses instructions to setup and working environment.
+
+This section will help you if you want to :
+* Get latest version of this container OS
+* Enhance container content by adding instruction in Dockefile before build step
+
+You must have a working environment with the source code of this repository. Read and follow [how to setup your working environment](https://github.com/startxfr/docker-images#setup-your-working-environment-mandatory) to get a working directory. The following instructions assume you are at the top level of your working directory.
+
+### Build & run a container using `docker`
+
+1. Jump into the container directory with `cd OS`
+2. Build the container using `docker build -t fedora .`
+3. Run this container 
+  1. Interactively with `docker run -it fedora`. If you add a second parameter (like `/bin/bash`) to will run this command instead of the default entrypoint. Usefull to interact with this container (ex: `/bin/bash`, `/bin/ps -a`, `/bin/df -h`,...) 
+  2. As a daemon with `docker run -d fedora`
+
+
+### Build & run a container using `docker-compose`
+
+1. Jump into the container directory with `cd OS`
+2. Run this container 
+  1. Interactively with `docker-compose up` Startup logs appears and escaping this command stop the container
+  2. As a daemon with `docker-compose up -d`. Container startup logs can be read using `docker-compose logs`
+

+ 25 - 0
sx.sh

@@ -0,0 +1,25 @@
+#!/bin/bash
+export TERM=xterm
+pid=0
+
+function display_container_header {
+    echo "+====================================================="
+    echo "| Container   : $HOSTNAME"
+    echo "| OS          : $(</etc/redhat-release)"
+    echo "| kubernetes  : $KUBERNETES_SERVICE_HOST"
+    echo "| user        : $(whoami)"
+    echo "+====================================================="
+}
+
+function start_service {
+    echo "+====================================================="
+    echo "| Container $HOSTNAME is now RUNNING"
+    echo "+====================================================="
+    while true
+    do
+      echo "live... (next try in 10sec)" & sleep 10
+    done
+}
+
+display_container_header
+start_service