How to create a new Docker image?

maxresdefaultIn this article we’re going to build one new docker image with Apache and PHP installed and one php file for test.

Create a directory called “build”:

# mkdir ˜/build

Change to directory “build”:

# cd ˜/build

Create a new file called Dockerfile with the following content:

FROM centos
MAINTAINER Daniel Nascimento
RUN yum update -y
RUN yum install httpd php -y
ADD index.php /var/www/html/
CMD /usr/sbin/apachectl -D FOREGROUND
EXPOSE 80

In the same directory create another file called index.php with the following content:

<?php
phpinfo();
?>

Finally it’s time of build our new image.

# docker build -t user/httpd .

Now we have a new image with apache and php installed. Then let’s create a new container using this image:

# docker run -t -i -p 80:80 user/httpd

To access our new container in your browser type the URL:

http://your-host-ip/

That’s it! 🙂

How to create a new OpenShift Origin user?

Basic Auth is used by default by the OpenShift Origin. So to create a new user account using the below command:

#htpasswd /etc/openshift/htpasswd username

Environment:

  • OpenShift V2
  • Centos 6 – 64Bits

Reference:

http://docs.openshift.org/origin-m4/oo_deployment_guide_comprehensive.html#configure-an-authentication-plugin

How to Install and set up GitHub on Centos 7

First let’s install Git:

# yum install git -y

Use the follow commands to add in the required information:

$ git config --global user.name "NewUser"
$ git config --global user.email newuser@example.com

Create a directory called myproject for our workspace environment:

$ mkdir myproject/

Change to directory myproject/.

$ cd myproject/

Create a new file called teste.txt

$ touch teste.txt

Initialized a new empty repository:

$ git init

Add the file created early called teste.txt to the new created repository:

$ git add teste.txt (Add only file teste.txt)

or

$ git add . (Add all files)

To commit the changes, use the command:

$ git commit -m “Explaining the changes” -a (To commit all files)

or

$ git commit -m “Explaining the changes” teste.txt (To commit only file teste.txt)

Pushing changes to a remote server

To add a new remote repository, use the command:

$ git remote add origin git@github.com:user/myproject.git

To push your local repository to a remote repository use the command:

$ git push origin master

Reference: https://github.com/

LVM – How to migrate data between disks?

Environment:

Red Hat Enterprise Linux Server 6.0

Case:

You have a server connected in storage A and need migrate the data to new storage B.

How to migrate data between disks with the server online?

In this article I will explain how migration of data between the disks, without unavailability, remember that in our example we’re using LVM.

This article assumes that the new disk has been installed on the system and is visible to the operating system as /dev/sdb.

Create a new partition of type LVM in new disk:

Create a new PV:

# pvcreate /dev/sdb1

Add the new PV to VG:

# vgextend VG_NAME /dev/sdb1

Move data between disks with command:

# pvmove -v /dev/sda1

The command pvmove will move data from disk sda1 to sdb1:

Check if the PV was released with command:

# pvs

Now remove the old disk from the VG with command:

# vgreduce -a

The option -a remove from VG all the PV free. In our exemple the disk sda1.

Now the disk can be removed from the server.

Linux – How to find duplicate IP address?

This is a quick tip to find duplicate IP address in your local LAN network.

To find duplicate IP address, you can use arping command under linux.

Example:

#arping -D 192.168.0.10

Output:

# arping -D 192.168.0.10 132

ARPING 192.168.0.10 from 192.168.0.2 eth0

Unicast reply from 192.168.0.10 [00:0C:29:2A:3C:C7]  0.896ms

Unicast reply from 192.168.0.10 [00:0C:29:55:B7:DB]  0.923ms

Where the option -D mean: duplicate address detection mode.

In our example there is duplicate IP address in local LAN network.

How to authenticate against the Active Directory by using Winbind

This article describes how to join an Red Hat in an Active Directory domain and to authenticate the user with AD.

Environment

Red Hat Enterprise Linux Server release 6.3
Windows Server 2008 R2

Install

You need to install the following packages:

# yum install samba-client  samba-winbind samba-winbind-clients

Configure

Open the /etc/samba/smb.conf file and modify as below:

[global]
workgroup = DOMAIN
realm = REALM.LOCAL
log level = 2
syslog = 0
server string = Linux File Server
security = ads
log file = /var/log/samba/%m
max log size = 50
printcap name = cups
printing = cups
winbind enum users = Yes
winbind enum groups = Yes
winbind use default domain = true
winbind separator = +
idmap uid = 1000000-2000000
idmap gid = 1000000-2000000
template shell = /bin/bash

Now, join to domain:

# net ads join -U Administrator

Start winbind and enable it on boot.

# service winbind start
# chkconfig winbind on

Verify the system can talk to AD with the commands:

Checks whether the trust secret via RPC calls succeeded.

# wbinfo -t

Lists all domain users.

# wbinfo -u

Lists all domain groups.

# wbinfo -g

Now let’s go configure the NSS and PAM.

# authconfig –enablewinbind –enablewinbindauth –smbsecurity=ads –smbrealm=<realm> –smbworkgroup=<workgroup> –smbidmaprange=1000000-2000000 –winbindtemplateshell=/bin/bash –enablewinbindusedefaultdomain –winbindseparator=+ –enablemkhomedir –updateall

Where:

enablewinbind: enable winbind for user information by default.
enablewinbindauth: enable winbind for authentication by default.
smbsecurity: security mode to use for samba and winbind.
smbrealm: default realm for samba and winbind when security=ads.
smbworkgroup: Classic (pre Windows 2003 Server) name of domain.
smbidmaprange: configures winbind to assume that users with no domain in their user names are domain users.
winbindtemplateshell: the shell which winbind-created users will have as their login shell.
enablewinbindusedefaultdomain: configures winbind to assume that users with no domain in their user names are domain users.
winbindseparator: the character which will be used to separate the domain and user part of winbind-created user names if winbindusedefaultdomain is not enabled.
enablemkhomedir: create home directories for users on their first login.
updateall: update all configuration files.

Follow some commands to test the configuration:

# getent passwd <user>
# id <user>
# getent group <domain group>

Done! Your linux system is authenticating against on Active Directory.