Running a local insecure Docker Registry for testing

To start and run a local Repository for sharing images between machines (from here):

docker run -d -p 5000:5000 --restart=always --name registry registry:2

To tag a local image and push it into your repository:

docker tag imagename [ip of your docker machine]:5000/imagename

And then push it into your repo:

docker push [ip of your docker machine]:5000/imagename

By default, the docker client fails when attempting to push an image to a locally running registry if you haven’t configured TLS and certificates. If you’re running a registry locally for testing, you can configure the local client to trust an insecure Registry by:

  • docker-machine ssh [name of docker machine]
  • sudo vi /var/lib/boot2docker/profile
  • Add this line to the EXTRA_ARGS var:
--insecure-registry=[ip of your docker machine]:5000

This tip from this article.

Update1: if running on Linux (no docker-machine), add the above property to /etc/default/docker and then

sudo service docker restart

Update2: if docker is running as a service using systemd (e.g. the Hypriot Raspberry Pi image), you need to edit

/etc/systemd/system/docker.service

… append the –insecure-registry option to the end of the line that starts: ExecStart (further details here)

Now trying the push again, and success!

$ docker push 192.168.99.100:5000/spring-boot-rest-alpine

The push refers to a repository [192.168.99.100:5000/spring-boot-rest-alpine]

d5a685774b12: Pushed 

726baddb2cde: Pushed 

bb81ee534db3: Pushed 

77f08abee8bf: Pushed 

latest: digest: sha256:cafa45a64cf25533a1544f37ef7ee3fac614cb2a8d8be30efe9b3c84cebabc52 size: 1159

Fixing wifi dropouts on Raspbian / Raspberry Pi

From this article, if you’re using one of the Wifi dongles on a Pi 1 or 2 (Pi3 has built in wifi), you can prevent the random dropouts during periods of inactivity by:

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

and then paste in and save this:

options 8192cu rtw_power_mgnt=0 rtw_enusbss=1 rtw_ips_mode=1

and then reboot.

Inline text replacement with sed

Replacing values in files is incredibly easy with sed. Here’s some examples:

 

sed 's/match/replace/g' file.txt

Find match, replace with replace, globally (all matches), in file.txt

 

sed 's/match/replace/g' file.txt > file2.txt

Same as before, but write results to new file, file2.txt

 

sed -n 's/match/replace/p' file.txt

-n suppresses output of the results, but /p prints out just the matching patterns that are replaced.

 

sed -i.old 's/match/replace/g' file.txt

Replace matches in the input file with inline replace (-i), renaming original file file.txt.old and writing inline replace results to file.txt