Docker useful commands

This intends to be a list of easy to find useful commands for working with docker. If you are looking for information about docker go to  Docker docs homepage

Continue reading


Sharing Internet connection from your Linux

I want to share my Interent connection from my linux to another equipment.

First you have to enable NAT in your linux,
as root you must type:

# iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE

Then, logged as root, you have to enable IP forwarding.
There are two ways:

# sysctl -w net.ipv4.ip_forward=1


# echo 1 > /proc/sys/net/ipv4/ip_forward

Now you have to configure in your other device the IP of your linux as default gateway.

And that’s all folks!

If you have problems with iptables and you want to remove all the rules write:

iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT

Record screencast in Linux from command line

To record what appears on the screen or in an application you can use the program recordmydesktop 

To record the whole screen use:

$ recordmydesktop -o screencast.ogv

By default it uses a low frame rate and recods audio, If you want to use a higher frame rate without audio:

$ recordmydesktop --no-soundo --fps 24 -o screencast.ogv

Probably you want to record a window application, not the whole screen. To do that you fist need to know the Window id which can be obtained with the xwininfo command:

$ xwininfo 

xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

xwininfo: Window id: 0x1a00003 "5554:intel17"

  Absolute upper-left X:  1467
  Absolute upper-left Y:  122
  Relative upper-left X:  1
  Relative upper-left Y:  32
  Width: 712
  Height: 800
  Depth: 24
  Visual: 0x22
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x1a00010 (not installed)
  Bit Gravity State: ForgetGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +1467+122  -781+122  -781-128  +1467-128
  -geometry 712x800+1466+90

In this case we are trying to record from the Android emulator. I know that for this purpose, if your android emulator version is 4.4 or higher, you can use the following commands over command-line:

$ adb shell screenrecord /sdcard/demo.mp4
$ adb pull /sdcard/demo.mp4

But in this case we are going to record from the host PC. So, if you want to record some part of the window, in our example the window has 480px and the remainder are just window decorators, write the following:

recordmydesktop --no-sound --windowid 0x1a00003 --fps 24 --width 480  -o screencast.ogv