Category Archives: Linux

Dockerfile: “no such file or directory” error using ADD

Testing docker is really interesting, but sometimes it’s difficult to understand what’s wrong with some configuration.

A problem I found recently dealed with the ADD directive used in the Dockerfile. I was trying to start some services with supervisor but I got this error during the image build process

Step 19 : ADD supervisord.conf /etc/supervisor/conf.d/
2014/02/10 00:40:55 build: supervisord.conf: no such file or directory

The file was right there, in the same path of the Dockerfile, but docker couldn’t find it.

After a good read of the official documentation I learned the conxept of “build context”. When you are building an image, the source directory from which you are operating is the build context, but when you are building passing the Dockerfile from the standard input, there’s no build context!

So this is ok

$ docker build -t mydebian .

and this can’t work

$ docker build -t mydebian - < Dockerfile

Cache deb packages with apt-cacher-ng

I’m playing with Docker and I’m constantly tuning my Dockerfile to install the needed packages.

This continuous refinement forces the build process to download the same deb packages every time and it becomes an actual waste of time and bandwidth.

Solution

apt-cacher-ng is a service which can be run on a Debian or Ubuntu host and will serve as a local cache for deb packages from Debian or Ubuntu repositories.

That’s what I need because I’m on an Ubuntu machine emulating a Debian container.

Host setup

The setup is really easy:

# aptitude install apt-cacher-ng

After the installation I changed the bind address of the service to keep it local (I don’t need LAN exposure), I added my local proxy to reach the internet and I disabled ReuseConnections (see Problems):

root@yoda:/etc/apt-cacher-ng# diff acng.conf acng.conf.old 
28d27
< BindAddress: localhost 172.17.42.1
35d33
< proxy: http://127.0.0.1:5865
322d319
< ReuseConnections: 0

Client setup

On the client side it’s necessary to force apt requests to use the proxy.
In the Dockerfile I added

RUN echo 'Acquire::http::Proxy "http://172.17.42.1:3142";' > /etc/apt/apt.conf.d/90-apt-cacher.conf

which creates the configuration file read by apt-get or aptitude when downloading packages.

Problems

The apt-cacher-ng server seems buggy at least when used in conjunction with a regular proxy. Sometimes I get errors like these on the client side

Err http://http.debian.net/debian/ wheezy/main netbase all 5.0
500  Invalid header

one possible solution is to perform a

# apt-get update

on the host machine (it seems to help). Another useful setting is

ReuseConnections: 0

as explained before.

HP ProBook 4540s brightness control in Ubuntu 13.10

The HP ProBook 4540s is a good choice when you need a GNU/Linux machine, but there are some hit and miss on the details. The thing I found most tedious is the brightness controls using the keyboard: they simply don’t work at all.

My soloution

See the kernel parameters actually used:

$ cat /proc/cmdline 
BOOT_IMAGE=/boot/vmlinuz-3.11.0-15-generic root=UUID=8850c025-676a-4e8c-ac83-4ed1147b88d4 ro quiet splash vt.handoff=7

If there’s no reference to acpi_backlight, that’s the problem. Add the parameter to /etc/default/grub changing the following line from

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

to

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor"

Done

Debugging IO on Android

Android is Linux based, so there are some interesting way to monitor and debug IO activity especially on storage.

The one I found more useful is this:

  1. enable dumping of IO info
    echo 1 > /proc/sys/vm/block_dump
  2. observe kernel log
    cat /proc/kmsg
  3. make your analysis
  4. disable dumping of IO info
    echo 0 > /proc/sys/vm/block_dump

The output you will get is similar to this:
<7>[71477.927886] kswapd0(24): WRITE block 21240712 on mmcblk0p12 (8 sectors)
<7>[71477.928436] kswapd0(24): WRITE block 21410792 on mmcblk0p12 (8 sectors)
<7>[71477.928710] kswapd0(24): WRITE block 21240704 on mmcblk0p12 (8 sectors)
<7>[71477.929016] kswapd0(24): WRITE block 21240656 on mmcblk0p12 (8 sectors)
<7>[71477.929443] kswapd0(24): WRITE block 25427968 on mmcblk0p12 (8 sectors)
<7>[71477.929687] kswapd0(24): WRITE block 8 on mmcblk0p12 (8 sectors)
<7>[71477.930084] kswapd0(24): WRITE block 0 on mmcblk0p12 (8 sectors)
<7>[71478.086639] sdcard(159): READ block 23431168 on mmcblk0p12 (256 sectors)
<7>[71478.087036] sdcard(159): READ block 23430912 on mmcblk0p12 (8 sectors)
<7>[71478.258148] sdcard(159): READ block 23430920 on mmcblk0p12 (200 sectors)
<7>[71478.258514] sdcard(159): READ block 23431424 on mmcblk0p12 (8 sectors)
<7>[71478.266967] sdcard(138): READ block 23430656 on mmcblk0p12 (32 sectors)
<7>[71478.268798] sdcard(159): READ block 23430688 on mmcblk0p12 (64 sectors)
<7>[71478.269409] sdcard(159): READ block 23430752 on mmcblk0p12 (128 sectors)
<7>[71478.271484] sdcard(159): READ block 23430880 on mmcblk0p12 (32 sectors)
<7>[71478.600646] sdcard(138): READ block 23431432 on mmcblk0p12 (512 sectors)
<7>[71478.765136] sdcard(159): READ block 23431944 on mmcblk0p12 (256 sectors)
<7>[71478.958129] Compiler(412): READ block 327320 on mmcblk0p11 (8 sectors)
<7>[71478.958557] Compiler(412): READ block 327400 on mmcblk0p11 (48 sectors)

Tried on my rooted Galaxy Nexus with CyanogenMod 10.1.0-RC1.