środa, 28 stycznia 2015

Why running docker command returns "/var/run/docker.sock: permission denied"

/var/run/docker.sock: permission denied

$ docker ps
FATA[0000] Get http:///var/run/docker.sock/v1.16/containers/json: 
dial unix /var/run/docker.sock: permission denied.
Are you trying to connect to a TLS-enabled daemon without TLS?
First quick look at the /var/run/docker.sock file.
$ ls -l /var/run/docker.sock
srw-rw---- 1 root docker 0 sty 28 11:53 /var/run/docker.sock
The solution should be now clear - you can solve the issue by adding user you are logged in to the docker group.

So, let's do this:

$ sudo gpasswd -a ${USER} docker
There should be now a change in /etc/group file.
$ cat /etc/group | grep ^docker
Next you need start new terminal session to apply the change and check if you are in the docker group. Should be listed in the following command execution:
$ groups
If still cannot see docker in the groups you're in - and you run linux with graphical interface (eg Ubuntu) you may need basically restart machine. Once done restart your docker container (if you were not needed restarting machine in previous step ;)
$ sudo service docker.io restart
That's all, now docker ps should be no problem to run.

niedziela, 25 stycznia 2015

How to use rsync to synchronize two folders without overriding permissions

Very popular and easy to remeber rsync command is rsync -a source_dir target_dir . "-a" is equivalent of "-rlptgoD". What does it mean?? Let's analyze it step by step.
  • "-r" - reqursive
  • "-l" - copy symbolic links as symbolic links
  • "-p" - preserve permessions
  • "-t" - preserve modification dates
  • "-g" - preserve group
  • "-o" - preserve owner (works only with root account)
  • "-D" - preserve device files and special files
So to do the same as "-a" does we need to ommit "-p" switch.
rsync -rltgoD m/bdg .

wtorek, 13 stycznia 2015

Rsync - ERROR: rsync error: protocol incompatibility (code 2) at compat.c(171) [sender=3.0.6]

$rsync -av file.zip user@host:file.zip
protocol version mismatch -- is your shell clean?
(see the rsync man page for an explanation)
rsync error: protocol incompatibility (code 2) at compat.c(171) [sender=3.0.6]
This message can be somewhat misleading at first glance, but the key to solve this issue is answering what actually means "clean shell" ;). Most probably some MOTD is displayed in one of the config files (eg. .bashrc) when user starts new session. To check if it is a case try the following command:

ssh designer@ true | wc -c
If this command returns 0 that means there is no output produced.

środa, 7 stycznia 2015

Ubuntu - how to download Oracle JDK with single command

Downloading jdk from oracle download web page requires passing a cookie with request header. The template:
curl -LO ${URL} -H "Cookie: oraclelicense=accept-securebackup-cookie"

Java 8

curl -LO http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-x64.tar.gz -H "Cookie: oraclelicense=accept-securebackup-cookie"

Java 7

curl -LO  http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-x64.tar.gz -H "Cookie: oraclelicense=accept-securebackup-cookie"

Java 9 - early access

curl -LO http://www.java.net/download/jdk9/archive/b44/binaries/jdk-9-ea-bin-b44-linux-x64-23_dec_2014.tar.gz -H "Cookie: oraclelicense=accept-securebackup-cookie"
Alternatively you can use wget command
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-x64.tar.gz