EDUP 802.11n Mini Wi-Fi Adapter Sleeping

 

I bought some EDUP 802.11 N Mini Wi-Fi Adapters from China.  They’re cheap and do a fine job plugged into my Raspberry Pi’s.

However, by default, they always go to sleep which makes it difficult to connect to them via ssh etc.  To fix this, here’s what I did:

To identify the USB WLAN Adapter I did the following:

$ lsusb

Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Then:

$ lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/5p, 480M
        |__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=smsc95xx, 480M
        |__ Port 5: Dev 4, If 0, Class=Vendor Specific Class, Driver=rtl8192cu, 480M

From that I was able to derive that the WLAN adapter was using the rtl8192cu drivers.

A bit of Googling later, I was able to disable power management on the Wifi adapter, like this:

sudo nano /etc/modprobe.d/8192cu.conf

Add the following lines:

# Disable power management options
8192cu rtw_power_mgnt=0 rtw_enusbss=0

Reboot…

Run:

cat /sys/module/8192cu/parameters/rtw_power_mgnt

It should return 0 if the power management is off.

Bask in the glory of your WiFi adapter that stays up all the time 🙂

Deploy Watchtower in Docker

Watchtower is an application that will monitor your running Docker containers and watch for changes to the images that those containers were originally started from. If watchtower detects that an image has changed, it will automatically restart the container using the new image.

  • A 16 megabyte limit is set on the container, in this instance.
  • I’ve added a hostname for this container because Watchtower sends emails with the hostname of the Watchtower Docker container in the subject line.  By setting my own hostname instead of the default Docker generated hostname, I can glance at the email and see which of my hosts containers have just been updated.
  • Email notifications are configured using the container environment variables using the -e flags.  These can be omitted if you don’t want any notifications.
docker run -d \
  --name watchtower \
  --hostname=azure.dockerhost001 \
  --restart=unless-stopped \
  --memory=16mb \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e WATCHTOWER_NOTIFICATIONS=email \
  -e [email protected] \
  -e [email protected] \
  -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER=your.smtp.server \
  -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=your.smtp.username \
  -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=your.smtp.password \
  v2tec/watchtower \
  --cleanup

Deploy Portainer in Docker

Portainer is an Open-Source lightweight Management UI which allows you to easily manage your Docker Hosts or Swarm Clusters

  • Port 9000 of the container is published to the host
  • A 16 megabyte limit is set on the container, in this instance.
  • Data is persisted in a named volume called ‘portainer_data’
docker run -d \
  --name portainer \
  --restart=unless-stopped \
  --memory=16m \
  -p 9000:9000 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
  portainer/portainer

The container can also be deployed using the more explicit –mount flag which became available for standalone containers in Docker 17.06.

docker run -d \
  --name portainer \
  --restart=always \
  --memory=16m \
  -p 9000:9000 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  --mount source=portainer_data,destination=/data \
  portainer/portainer

Install Docker and Compose on Ubuntu 16.04 LTS

#!/bin/bash

apt-get update

apt-get install \
 apt-transport-https \
 ca-certificates \
 curl \
 software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

add-apt-repository \
 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
 $(lsb_release -cs) \
 stable"

apt-get update

apt-get install -y \
  docker-ce \
  docker-compose

If you plan on using the –memory flag when creating containers, you may need to enable memory and swap accounting in the Kernel.

  1. Log into the Ubuntu host as a user with sudo privileges.
  2. Edit the /etc/default/grub file. Add or edit the GRUB_CMDLINE_LINUX line to add the following two key-value pairs:
    GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
  3. Save and close the file.
  4. Update GRUB.
    $ sudo update-grub

    If your GRUB configuration file has incorrect syntax, an error occurs. In this case, repeat steps 3 and 4.

    The changes take effect when the system is rebooted.

More detailed information can be found in the Docker Post-Installation Steps for Linux.