Changing passwords from scripts (docker file)

You can run the passwd command and send it piped input. So, do something like:
echo thePassword | passwd theUsername --stdin
 
You could also use chpasswd:
echo username:new_password | chpasswd   
echo username:newpassword   | chpasswd
so, you change password for user username to new_password.

Docker container commands

check docker version
------------------------
docker version    

Search for image


docker search urgensherpa/lamp6
redhat@test:~/ssh_image$ docker search urgensherpa
NAME                        DESCRIPTION   STARS     OFFICIAL   TRUSTED
urgensherpa/lamp6                                        0                   

Pulling image
you@tutorial:~$ docker pull learn/tutorial
Pulling repository learn/tutorial from https://index.docker.io/v1
Pulling image 8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c (precise) from ubuntu
Pulling image b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc (12.10) from ubuntu
Pulling image 27cf784147099545 () from tutorial
you@tutorial:~$

Run commands in container   
docker run learn/tutorial echo "hello world"

installing things in the container

docker run learn/tutorial apt-get install -y ping  

docker ps -l
docker ps
=== ========== ========= =        ====================
docker commit 698989sdafd learn/ping  
====meaning==
698989sd...= container id
learn/ping = learn -username and ping - image
-----------------------------------------------------------
docker run learn/ping ping google.com      
Find info about docker container
--------------------------------
docker inspect efesdlfk     

docker images   = This will show you which images are currently on your host

docker push learn/ping   

fail2ban on Ubuntu 12.04 LTS

Simple fail2ban config
- - - - -- - - - - -  - --  - -
#sudo apt-get install fail2ban

Now to fine tune default configs

#cd /etc/fail2ban

#sudo vim jail.conf
#it also help protect ssh ftp apache asterisk ...
.
.
bantime  = 989898     ##in seconds
maxretry = 3     ##place your threshold value

#search for jails
#JAILS

[ssh]
enabled=true
port =ssh
filter = sshd
logpath = var/log/auth.log
maxretry = 3

save/exit
................................
#service fail2ban restart

Change language setting os = ubuntu 13.04

# vim /etc/default/locale

 //change to below param's if its like eg. LANG="np_NP"                                    
LANG="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
.
..
...

# sudo locale-gen

logout and login again

Autostart script at runtime /etc/rc.local


The /etc/rc.local file is common to major Linux distributions.
This file contains BASH commands which will be run after run-level specific commands whenever the system is booted.
In a VPS environment, /etc/rc.local is commonly used to store the hostname <SERVER_HOSTNAME>command (where <SERVER_HOSTNAME> is the intended hostname for the VPS) to ensure that the VPS hostname is not reset when the VPS is rebooted.
                                                                         Method 1                                     
redhat@cloud01:/etc/init.d$ nano rc.local 


  GNU nano 2.2.6                                      File: rc.local                                                                                    


        if [ -x /etc/rc.local ]; then

                [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
                /etc/rc.local
                ES=$?
                [ "$VERBOSE" != no ] && log_end_msg $ES
                return $ES
        fi
}

case "$1" in

    start)
        do_start
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac
###########################at the end of file >>>>

/root/script/mystartupscript1.sh

/root/script/mystartupscript2.sh  &    #mystartupscript2  & ==the & sends the script to background 
chown wso2:docker /var/run/docker.sock
modprobe aufs
sudo killall dnsmasq


##$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

                                                        Method 2  #vim   /root/scripts/mystartupscript1.sh
boot=$(date)
echo "the system boot at $boot " >> /var/log/custombootlog.log

#chmod u+x mystartupscript1.sh

#vim /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
#put your script/command here

chown wso2:docker /var/run/docker.sock
modprobe aufs
sudo killall dnsmasq
/root/script/mystartupscript1.sh
/root/script/mystartupscript2.sh &

exit 0


docker1&2 setup note

FLOATING_RANGE=192.168.140.0/27
FIXED_RANGE=10.11.12.0/24
FIXED_NETWORK_SIZE=256
FLAT_INTERFACE=eth1
ADMIN_PASSWORD=g
MYSQL_PASSWORD=g
RABBIT_PASSWORD=g
SERVICE_PASSWORD=g
SERVICE_TOKEN=g
SCHEDULER=nova.scheduler.filter_scheduler.FilterScheduler
VIRT_DRIVER=docker
SCREEN_LOGDIR=$DEST/logs/screen
----------------------------------------------------------------
 cat install_docke0.sh
#!/usr/bin/env bash

# **install_docker.sh** - Do the initial Docker installation and configuration

# install_docker.sh
#
# Install docker package and images
# * downloads a base busybox image and a glance registry image if necessary
# * install the images in Docker's image cache


# Keep track of the current directory
SCRIPT_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $SCRIPT_DIR/../..; pwd)

# Import common functions
source $TOP_DIR/functions

# Load local configuration
source $TOP_DIR/stackrc

FILES=$TOP_DIR/files

# Get our defaults
source $TOP_DIR/lib/nova_plugins/hypervisor-docker

SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}


# Install Docker Service
# ======================

# Stop the auto-repo updates and do it when required here
NO_UPDATE_REPOS=True

# Set up home repo
curl https://get.docker.io/gpg | sudo apt-key add -
install_package python-software-properties && \
    sudo sh -c "echo deb $DOCKER_APT_REPO docker main > /etc/apt/sources.list.d/docker.list"
apt_get update
install_package --force-yes lxc-docker-${DOCKER_PACKAGE_VERSION} socat
###############################################################################################
cat install_docke1.sh
#!/usr/bin/env bash

# **install_docker.sh** – Do the initial Docker installation and configuration

# install_docker.sh
#
# Install docker package and images
# * downloads a base busybox image and a glance registry image if necessary
# * install the images in DockerÂ’s image cache

# Keep track of the current directory
SCRIPT_DIR=$(cd $(dirname $0?) && pwd)
TOP_DIR=$(cd $SCRIPT_DIR/../..; pwd)

# Import common functions
source $TOP_DIR/functions

# Load local configuration
source $TOP_DIR/stackrc

FILES=$TOP_DIR/files

# Get our defaults
source $TOP_DIR/lib/nova_plugins/hypervisor-docker

SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}

# Install Docker Service
# ======================

# Stop the auto-repo updates and do it when required here
NO_UPDATE_REPOS=True

# Start the daemon – restart just in case the package ever auto-starts…
#restart_service docker

echo Waiting for docker daemon to start
DOCKER_GROUP=$(groups | cut -d' ' -f1)
CONFIGURE_CMD="while ! /bin/echo -e 'GET /v1.3/version HTTP/1.0\n\n' | socat - unix-connect:$DOCKER_UNIX_SOCKET | grep -q '200 OK'; do

echo failure
sleep 1
done"
if ! timeout $SERVICE_TIMEOUT sh -c "$CONFIGURE_CMD"; then
die $LINENO docker did not start
fi

Changing Priority Values for process/scripts

Changing priority of process/or running script :
-------------------------------------------------
Use top or ps
------------------------------------------------
eg. ./myscript.sh
#ps -ef | grep myscript
get the process id...
eg.4545
#ps -o pid,comm,nice -p 4545            //pid,,comm=command,nice=nice value of process , -p = processid, -o = outputformat

#ps -efl     <displays nice values>
....
......
#renice -15 -p 4545

// / nice value ranges from -20 to 19 ..negative value have higher priority(eg.-20 is highest priority and 19 have lowest , default priority is 0)
==============================================
To set nice value/ priority for process/script/cmd to be started
======================================================
#nice -n 10 apt-get upgrade
#nice -n -11 ./myscript.sh

user del mod etc..

Display list of shell
Code:
less  /etc/shells
cat  /etc/shells
more /etc/shells
Change the user login shell to /bin/ksh for foo user
Code:
chsh -s /bin/ksh foo
chsh -s /bin/bash username

-----------------
Adding user
-----------------
Syntax: # useradd -s <SHELL> -m -d <HomeDir> -g <Group> UserName


-s SHELL : Login shell for the user.
-m : Create user’s home directory if it does not exist.
-d HomeDir : Home directory of the user.
-g Group : Group name or number of the user.
UserName : Login id of the user.

Create Linux User with Custom Configurations Using useradd Command
-----------------------------------------------------------------------------
The following example creates an account (lebron) with home directory /home/king, default shell as /bin/csh and with comment “LeBron James”.

# useradd -s /bin/csh -m -d /home/king -c "LeBron James" -g root lebron

# grep lebron /etc/passwd

lebron:x:513:0:LeBron James:/home/king:/bin/csh
 -------------------------
Verify user information:
-------------------------
# finger david

Output:

Login: david                      Name: david gilmour
Directory: /iscsi/user/vivek                Shell: /bin/bash
Last login Thu Sep 13 07:58 2007 (IST) on pts/1 from 10.16.15.2
No mail.
No Plan.
------------------------------------------------------------------------------------------------------
You can use the usermod command. The following (run as root) will change the user smith's 
home directory to /tmp/smith and move all of their files with it.

Code:
usermod -m -d   /tmp/smith smith


Add an Existing User to a Group
Next we’ll add a user to the group, using this syntax:
usermod -a -G <groupname> username
eg. usermod -a -G dockergroup  stackuser

Retain Un allocated space in USB drive


C:\Users\New Tech>diskpart
Microsoft DiskPart version 6.2.9200

Copyright (C) 1999-2012 Microsoft Corporation.
On computer: NPLP05

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          465 GB      0 B
  Disk 1    No Media           0 B      0 B                                 //this is dvd/cd ROM
  Disk 2    Online           14 GB      0 B

DISKPART> select disk 2

Disk 2 is now the selected disk.

DISKPART> clean

DiskPart succeeded in cleaning the disk.

DISKPART> create partition primary

DiskPart succeeded in creating the specified partition.

DISKPART> exit

Leaving DiskPart...

C:\Users\New Tech> / // the partition of usb drive is in FAT by default

Block Level Storage & File Level Storage

Anyone who has used a Storage Area Network (SAN) has probably used block level storage before. Block level storage presents itself to servers using industry standard Fibre Channel and iSCSI connectivity mechanisms. In its most basic form, think of block level storage as a hard drive in a server except the hard drive happens to be installed in a remote chassis and is accessible using Fibre Channel or iSCSI.

 When it comes to flexibility and versatility, you can't beat block level storage. In a block level storage device, raw storage volumes are created, and then the server-based operating system connects to these volumes and uses them as individual hard drives. This makes block level storage usable for almost any kind of application, including file storage, database storage, virtual machine file system (VMFS) volumes, and more. You can place any kind of file system on block level storage. So, if you're running Windows, your volumes will be formatted with NTFS; VMware servers will use VMFS.
Remember, when you use a block-based volume, you're basically using a blank hard drive with which you can do anything.
From a use case standpoint, there are a lot of applications that make use of this block-level shared storage, including:
  • Databases. This is especially true when you want to cluster databases, since clustered databases need shared storage.
  • Exchange. Although Microsoft has made massive improvements to Exchange, the company still does not support file level or network-based (as in, CIFS or NFS) storage. Only block level storage is supported.
  • VMware. Although VMware can use file level storage via Network File System (NFS), it's very common to deploy VMware servers that use shared VMFS volumes on block level storage.
  • Server boot. With the right kind of storage device, servers can be configured to boot from block level storage.
 File level storage is usually accessible using common file level protocols such as SMB/CIFS (Windows) and NFS (Linux, VMware). In the block level world, you need to create a volume, deploy an OS, and then attach to the created volume; in the file level world, the storage device handles the files and folders on the device.


The two most popular storage system technologies are file level storage and block level storage. File level storage is seen and deployed in Network Attached Storage (NAS) systems. Block level storage is seen and deployed in Storage Area Network (SAN) storage. In the article below, we will explain the major differences between file level storage vs. block level storage. File Level Storage - This storage technology is most commonly used for storage systems, which is found in hard drives, NAS systems and so on. In this File Level storage, the storage disk is configured with a protocol such as NFS or SMB/CIFS and the files are stored and accessed from it in bulk.
  • The File level storage is simple to use and implement.
  • It stores files and folders and the visibility is the same to the clients accessing and to the system which stores it.
  • This level storage is inexpensive to be maintained, when it is compared to its counterpart i.e. block level storage.
  • Network attached storage systems usually depend on this file level storage.
  • File level storage can handle access control, integrate integration with corporate directories; and so on.
Block Level Storage - In this block level storage, raw volumes of storage are created and each block can be controlled as an individual hard drive. These Blocks are controlled by server based operating systems and each block can be individually formatted with the required file system.
  • Block level storage is usually deployed in SAN or storage area network environment.
  • This level of storage offers boot-up of systems which are connected to them.
  • Block level storage can be used to store files and can work as storage for special applications like databases, Virtual machine file systems and so on.
  • Block level storage data transportation is much efficient and reliable.
  • Block level storage supports individual formatting of file systems like NFS, NTFS or SMB (Windows) or VMFS (VMware) which are required by the applications.
  • Each storage volume can be treated as an independent disk drive and it can be controlled by external server operating system.
  • Block level storage uses iSCSI and FCoE protocols for data transfer as SCSI commands act as communication interface in between the initiator and the target.