Monday, December 14, 2015

Deleting docker images based on condition or filter

I posted about deleting docker containers and deleting images.Sometimes we need to clean only some images based on a condition.

I am adding to commands to delete untagged images.You can grep on any value you like.

#Deleting untagged images
docker rmi $(docker images | grep none | awk '{print $3}')

Saturday, December 12, 2015

Difference between role and cookbook in chef

A role may be made up of one of more cookbooks whereas cookbook is a single entity made up of recipes.

So roles can be used to simplify run lists.
Instead of providing a run list with all the cookbooks a role can be provided.

{
 run_list : [
    "role[test]"
 ]
}

can be used instead of
{
 run_list : [
    "recipe[test1]",
    "recipe[test2]",
    "recipe[test3]"
 ]
}

Difference between ADD and COPY in docker

The commands for deleting the containers and images are
The major difference is that ADD can do more than COPY:
  • ADD allows the source to be an URL
  • Also If the  parameter of ADD is an archive in a recognised compression format, it will be unpacked

Friday, December 11, 2015

Remove docker images and containers

When we use docker we end up running a lot of containers and creating a lot of images

The commands for deleting the containers and images are

#docker stop all containers
docker stop $(docker ps -a -q)

#docker remove all containers
docker rm $(docker ps -a -q)

#docker remove all images
docker rmi $(docker images -q)

Wednesday, September 23, 2015

Getting started with UNIX - Basic commands


List of basic commands of unix

reboot - Immediately stops all running processes, shuts down the system, then reboots.
sudo - Runs commands as root, which means no limitations due to permissions.

shutdown - Stops all running processes and shuts down the system.
Parameters can be specified to issue a delayed shutdown or a shutdown at a particular time.

date - Prints out the current system date and time.
Specified parameters can change the format of the output.

df - Reports the disk space usage for the file system.
hostname - Displays the name of the current host system.
ps - Displays information about all of the processes currently running on the system.
du - Disk usage
ps - List running processes

To know the process id of a process running
 ps -elf | grep process_name
 ps -fA | grep process_name

| -> pipe character is very useful for redirecting output of one command to other
 grep is used to find the pattern

To create a file
 cat filename
 touch filename

To search something in a file
 grep -i thing_to_be_searched filename

To search something across directories
 grep -rn pattern_to_be_searched directory_starting_from_where_search_to_be_started 

To view processes along with the memory they are consuming run
 top
Ctrl + M will sort in decreasing order of memory consumption

chmod / chown - Changes the access permissions of one or more files (chmod) or
changes the ownership of a particular file to a new user (
chown).
Only users with permission or ownership of a file can change that file’s permissions or ownership.

chown owner_name filename
chmod 755 filename  

Here 7 is the permission for owner
5 and 5 for group and others respectively

7 - xrw
5 - xr
2-r
4-x
1-w

Access permissions are of three types
 x Execute permissions (4)
 r Read permission (2)
 w write permissions (1)

Aur linux has concept of owner, group and others.

Owner is the owner of the file
Every file or directory belong to a group
And third is others(not owner and not belonging to the group of the file)

Permissions are in the order Owner permissions Group permissions  others permissions