Applications


How to List all Docker Container Names and their IPs 4

The following command will make a list with all docker container names and their respective IPs.
For the containers that have multiple IPs it will printed them on the same row as their name.


docker ps -q | xargs -n 1 docker inspect --format '{{ .Name }} {{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' | sed 's#^/##';


How to update all pulled Docker images that are tagged as latest

Recently, we moved a client to Docker and we needed to give them a way to automagically update all “latest” Docker images.
Since Docker does not have a single command to update all pulled images we used this one-liner to update all images at once:


docker images --format "{{.Repository}}:{{.Tag}}" | grep ':latest' | xargs -L1 docker pull;

The above command will:

  1. Print all images in the format RepositoryName:Tag
  2. Then it will filter all lines that end with the suffix :latest (which is the tag we are interested in)
  3. Finally, for each result (which is one per line) it will be fed  via the command xargs -L1 to the command docker pull

Please note that you cannot really update an existing container using docker commands, what you need to do is actually:

  1. Stop the container whose image was updated
  2. Delete it
  3. Recreate it using the parameters of the previous container

As you understand, it is a good practice to save all of your data in volumes outside the container to make the update process easy.

For example, below you will find the commands using which we updated the jwilder/nginx-proxy and the jrcs/letsencrypt-nginx-proxy-companion images along with the two containers that were using them:


docker container stop nginx-proxy nginx-letsencrypt;
docker container rm nginx-proxy nginx-letsencrypt;
docker run -d -p 443:443 \
     --name nginx-proxy \
     --net reverse-proxy \
     -v $HOME/certs:/etc/nginx/certs:ro \
     -v /etc/nginx/vhost.d \
     -v /usr/share/nginx/html \
     -v /var/run/docker.sock:/tmp/docker.sock:ro \
     -v $HOME/my_proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro \
     --label com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true \
     jwilder/nginx-proxy:latest;

docker run -d \
     --name nginx-letsencrypt \
     --net reverse-proxy \
     --volumes-from nginx-proxy \
     -v $HOME/certs:/etc/nginx/certs:rw \
     -v /var/run/docker.sock:/var/run/docker.sock:ro \
     jrcs/letsencrypt-nginx-proxy-companion:latest;


[Video] Android OpenCV – Face Detection and Recognition Demo

Android OpenCV – Face Detection and Recognition Demo using Android NDK/JNI to load OpenCV library.

Google Play: https://play.google.com/store/apps/details?id=net.bytefreaks.opencvfacerecognition

Get it on Google Play

Our application is based on the ‘Face Detection’ sample of OpenCV. The sample that is available for download from http://sourceforge.net/projects/opencvlibrary/files/opencv-android/, you will notice that there are many versions there, we used version opencv-2.4.13.6-android-sdk. Refer to this (http://docs.opencv.org/2.4/doc/tutorials/introduction/android_binary_package/O4A_SDK.html) introduction for more information.


How we sync files between two drives

The rsync command is a powerful tool for file synchronization and transfer in Linux and Unix-like operating systems. It provides a robust and efficient way to copy, backup, and mirror files and directories both locally and remotely. In this article, we will explore the technical details of the following rsync command:

rsync -avh --delete --progress "path/to/source/" "path/to/destination/";

We will explain each option and argument used in the command and their respective functionality.

Options and Arguments

The rsync command is a versatile tool with many options and arguments to customize its behavior. The options used in the above command are:

  • “-a”: This option enables the archive mode, which is a shorthand for several options such as -rlptgoD, -l, -p, -t, -g, -o, and -D. It ensures that rsync preserves file permissions, ownership, timestamps, and symbolic links during the synchronization process.
  • “-v”: This option enables verbose mode, which displays detailed output of the rsync operation, including the transferred files and their sizes.
  • “-h”: This option enables human-readable mode, which displays file sizes in a more readable format, such as “1K” for 1 kilobyte, “1M” for 1 megabyte, etc.
  • “–delete”: This option tells rsync to delete any files at the destination that do not exist at the source. This ensures that the destination is an exact copy of the source.
  • “–progress”: This option displays real-time progress information during the rsync operation, including the percentage of completion and the estimated time remaining.

The arguments used in the command are:

  • “path/to/source/”: This argument specifies the source directory or file that we want to sync. It can be a local path or a remote path using the ssh protocol.
  • “path/to/destination/”: This argument specifies the destination directory or file where we want to copy the source files. It can also be a local or remote path using the ssh protocol.

Explanation

The rsync command is a powerful tool that synchronizes the source and destination directories or files. The -a option enables the archive mode, which ensures that the file metadata is preserved during the transfer, including permissions, ownership, timestamps, and symbolic links. The -v option enables the verbose mode, which provides detailed output of the rsync operation, including the transferred files and their sizes.

The -h option enables the human-readable mode, which displays file sizes in a more readable format. The –delete option tells rsync to delete any files at the destination that do not exist at the source, which ensures that the destination is an exact copy of the source. Finally, the –progress option displays real-time progress information during the rsync operation, including the percentage of completion and the estimated time remaining.

Conclusion

The rsync command is a powerful tool for file synchronization and transfer in Linux and Unix-like operating systems. The command discussed in this article synchronizes the source and destination directories or files, preserves file metadata, displays detailed output, deletes any files that do not exist at the destination, and displays real-time progress information. With the proper use of rsync options and arguments, file synchronization and transfer can be made easy, efficient, and reliable.

Other

We have two external hard disks that we use to keep backups of our data.
The way we do that is by using the command rsync that makes our life easy.

Specifically, we use the following command to synchronize the first hard disk with the second one: rsync -avh –delete –progress “path/to/source/” “path/to/destination/”;

rsync is a fast, versatile, remote (and local) file-copying tool, it is available in almost every system (GNU/Linux, Unix (MacOS as well) and Windows).

The parameters we use are the following:

  • -a, --archive enables archive mode which is equal to -rlptgoD (no -H,-A,-X)
    In more detail it enables all of the following options
    -r, --recursive recurse into directories
    -l, --links copy symlinks as symlinks
    -p, --perms preserve permissions
    -t, --times preserve modification times
    -g, --group preserve group
    -o, --owner preserve owner (super-user only)
    -D same as --devices --specials
    --devices preserve device files (super-user only)
    --specials preserve special files
  • -v, --verbose it increases verbosity of the output
  • -h, --human-readable outputs numbers in a human-readable format
  • --delete deletes extraneous files from destination directories
  • --progress shows progress during transfer