30 basic commands to start with Docker Container

It’s been a long time, I did not blog anything about Docker. In the article Installing, Updating and Playing around with a Docker container that dated back to the year 2016, I showed some basics on Docker installation and some basic commands to start with. Time to dive a little bit deeper into the basics of Docker. For installation on Fedora Operating system, please see the official installation of Docker on the Docker webpage. All commands and illustrations on this blog post have been tested on Fedora. Once Docker installed, there are various interesting commands you can adventure around.

Starting up with Docker containerization

1. Searching for CentOS image with the most stars:

docker search --filter=stars=100 centos

2. You can also pull an image:

docker pull centos

3. To view the images, simply do this:

docker images

4. You can also run the container/images

docker run  -it --name=centostunnelix centos /bin/bash

5. When you run containers and even after exiting, you cannot re-run it again, because that container name, in my case centostunnelix, was used previously. Note that the container has been stopped and not removed! You will find it stopped using the following command:

docker ps -a

6. You can now start the container back:

docker start centostunnelix

7. And after starting it, you can simply stop the container:

docker stop centostunnelix

8. You can also gracefully remove it:

docker rm centostunnelix

9. Also renamed it to another instance, for example, centosprod in this case:

docker rename centostunnelix centosprod

10. A Docker in exited mode means that the changes you made are still there. However, it is still not running. You can now run it either by connecting directly to it or simply run it in the background and attach to it whilst it is running.

docker start centosprod
docker attach centosprod

Warming up with Docker…

11. Moreover, if you need to detach from the container without stopping it, you simply need to do the following two key combination one after each other. It is a good practice to check it using docker ps -a though:

Ctrl+p and Ctrl+q

12. But this keys combination can be painful and as a good practice after starting a Docker container, use the following command to get into the container and by typing Ctrl+d or exit to keep your container still up and running:

docker exec -it centosprod /bin/bash 

13. To get the last container that you have run using the following command:

docker ps -l

14. To see all the commands that have been executed inside a container with its timestamp, use the following command:

docker logs centosprod -t

15. You can also pause and unpause containers which are actually freezing and unfreezing it using the following commands:

docker pause centosprod
docker unpause centosprod

16. Imagine you want to run a container, but as soon as you exit from the container, it should get destroyed immediately. For that to be done, you need to start the container with the following command:

docker run --rm --it centosprod /bin/bash

Docker Hub

17. The Docker Hub is a library and community for Docker container images. You can access it at hub.docker.com and created an account to it. Then, from your Terminal, use the following command to log in to the Docker Hub.

docker login

18. As explained in part 3, to see the list of images created, you can use docker images. Note that image ID is the same. However, to push an image to your repository, firstly, you need to give a tag to the image using the following command:

docker image tag centos thetunnelix/centostunnelix

19. By now, if you launch again the command docker images, you will see the same images under a new name tag. To upload it to your repository using the following command:

docker image push thetunnelix/centostunnelix

20. You can also delete an image locally using the following command:

docker image rm -f centostunnelix

21. To retrieve back your image use the following command:

docker pull thetunnelix/centostunnelix

Let’s dive into Networking

22. Once into the Docker container, the command ipconfig is not present. I have installed the package net-tools using the command yum install net-tools -y. After installing the package, after firing an ipconfig, you would notice that the network card has been assigned with an IP address. On your physical machine, launch the following command to see your connection names, UUID, Type and Devices. You will see a connection name docker0 as a bridge:

nmcli connection show

23. To see how many virtual connected devices to docker0, you can use the following command:

brctl show docker0

24. Since Docker, create a virtual bridge on the machine, you can also see it using the following command:

docker network ls

25. To get more details about the network configuration of each container use the following:

docker network inspect bridge

26. So, we have seen by default docker create a bridge and all containers are assigned IP from that bridge only. However, we can also create another bridge and also specifying the gateway as well as the subnet which is pretty interesting:

docker network create tunnel0 --subnet 10.0.0.0/24 --gateway 10.0.0.1

27. Once you have created a new network bridge, you can use again the command docker network ls and docker network inspect bridge to confirm if the bridge has been created. Now, to start a container in the subnet 10.0.0.0/24, simply use the following command that was used in step 4 but this time with the argument –net <name of virtual bridge>:

docker run -it --net tunnel0 --name=centosprodnew centos /bin/bash

28. In step 27, we have seen how to create a container for a particular network. Imagine that you want to attach the same container to “bridge” that has been created by default. You would notice it using the command docker network ls. To connect it to “bridge”, use the following command.

docker network connect bridge centosprodnew

29. To disconnect it from “bridge”, simply do the following:

docker network disconnect bridge centosprodnew

30. To get logs at host level launch the following command:

journalctl -u docker.service

Tips:

  • You can run directly an image, for example, docker run fedora even if you did not pull it. Docker will automatically pull it and run it for you.
  • Every time you run a container with a different container name, it will assign a unique ID to it under the directory /var/lib/docker/containers. For every container, you have a unique ID and docker ps -aq will show you the containers.
  • When a name is not specified when starting a Docker container, Docker will assign names to it; it could be a really funny name.
  • Imagine that you are exiting from a container and you want the container to be removed automatically.
  • Always remember, whenever you start a Docker container, a unique ID will be allocated to the container and a filesystem will be allocated and mounts as Read/Write for the container. It will also allocate a Network/Bridge interface following an IP assignment and finally the process execution by the user.
  • By default, all Docker containers will be assigned an IP address range from docker0.
  • You can also create a container by using the argument –hostname and by default docker will append the /etc/hosts file with the IP and hostname of the container.
  • Virtual network binds to the bridge which creates a virtual subnet shared between the host and every virtual container. It’s basically a NAT rule that allows containers to talk to the internet but not the other way around. This concept is similar to the option of NAT in Virtual Box.
  • In step 28, “bridge” is the name of the virtual bridge that has been created by default in Docker.

If you liked these Docker basics and have any question please comment below. In future articles, I will focus on building Docker images and publish ports, Docker Swarm, Kubernetes with Docker, Metrics, and Monitoring of Docker containers etc.


30 basic Powershell commands to start with Windows Server

Getting started with Windows 2019 nano server can be very challenging especially if you are not used to CLI on Linux servers. I decided to install Windows 2019 server core only i.e; without GUI and take it as a challenge to learn more about it. Since I’m mostly from a Unix/Linux background, I decided to dive a little bit more in the Windows Operating system. In this article, I’m sharing some commands to start with. However, the Microsoft website covers enough part which will lead to the Windows 2016 MCSE certification. My goal in this article is to get PowerShell beginners on track and paint an idea of what Windows Powershell is capable of.

Windows Updates

1. Some modules are not available by default on the PowerShell. So you will need to manually download it. I downloaded the module PSWindowsUpdate which will enable me to update the OS from PowerShell.

Get-Module PSWindowsUpdate

2. One of the first things you might want to do is to get the updates that need to be installed on  the Operating System first which I did with the following command:

Get-WindowsUpdate

3. Now you can install the updates using the following command. Once installed, reboot the server which might take some time.

Install-WindowsUpdate

4. You can also find the list of updates installed on the machine using the following command:

Get-Hotfix

OS basic verification

5. To get the version of the PowerShell, use the following command:

  • Get-host | select Version
  • $PSVersionTable

6. To get the reboot history :

Get-EventLog system | where-object {$_.eventid -eq 6006} | select -last 10

7. List of services running:

Get-Service

8. List of Installed programs:

Get-Module PSWindowsUpdate
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize

9. Get the process running on Windows

Get-process

Networking

10. Finding the rules on the firewall:

Get-NetFirewallRule

11. IP configuration:

Get-NetIPConfiguration

12. To verify if IPv4 or IPv6 is enabled or not

Get-NetAdapterLso

13. To get the routing table

Get-NetRoute

14. Source and remote IPs on listening mode

Get-NetTCPConnection | ? {$_.State -eq "Listen"}

Storage

15. Get the disk space information

Get-WmiObject win32_logicaldisk
Get-PhysicalDisk

16. To get the health status of the disk:

Get-PhysicalDisk | Sort Size | FT FriendlyName, Size, MediaType, SpindleSpeed, HealthStatus, OperationalStatus -AutoSize

17. Getting the used/free space:

Get-PSDrive C | Select-Object Used, Free

PowerShell Modules and repository

18. The PowerShell Gallery is the central repository for PowerShell content. You can find new PowerShell commands or Desired State Configuration (DSC) resources in the Gallery. To check which repository you are using use the following :

get-PSRepository

19. By default, PowerShell modules are installed in several directories. You can download certain modules in any directory you want. To execute it, you need to append the environment. To see the module paths of your environment, launch the following command:

$Env:PSModulePath

20. To add a path to the environment’s module path, use the following command:

$env:PSModulePath = $env:PSModulePath + ";C:\ModulePath"

21. To get a list of installed modules and the directories in which it has been installed:

Get-Module -ListAvailable

22. To install a module, you can search for it and install it directly:

find-module -Name PendingReboot | install-module 

23. After installing a module, it is always a good practice to import it using the following:

Import-Module PendingReboot

24. To get information which command to use for a pending reboot use:

Get-Command -Module PendingReboot

Downloads and unzip

25. Recently, I saw a link where having a script on Technet. You can use the following command to download the zip file.

Invoke-WebRequest https://gallery.technet.microsoft.com/scriptcenter/Get-RebootHistory-bc804819/file/130620/2/Get-RebootHistory.zip -outfile Get-RebootHistory.zip

26. To unzip a file:

Expand-Archive -path '.\Get-RebootHistory.zip' -DestinationPath 'C:\Users\Administrator\Documents\WindowsPowerShell\Modules'

Getting Help

27. Getting help with commands arguments are pretty easy. Let’s say you want to know the possible arguments of the command Get-Command, simply do:

Get-Command -?

28.  You can also use the Get-Help module. For example, consider the Compress-Archive module:

Get-Help -name Compress-Archive

29. Consider that you need an example of a specific module:

Get-Help -name Compress-Archive -examples

30. The help/man command is also interesting to get fast syntax about a command.

man Compress-Archive
help Compress-Archive

One interesting source of information is gallery.technet.microsoft.com/scriptcenter where you can access several scripts for Microsoft Windows Server Administration. Personally, Windows PowerShell commands seem to be more complexed compared to Linux commands. Probably, its a matter of getting used to it. I will try my best to update this article. Don’t forget to comment below if needed. My last article on Windows was on the installation of SSH on Windows server through Powershell.


My trip to Pension Cargo, Bras-Panon – Reunion Island

I had a splendid time in Reunion Island this week. I stayed at “Pension Cargo” which is owned by Christian, a friend at Bras-Panon, Reunion island in the north-east of the neighbor island thirty minutes away from Roland-Garros, St-Denis Airport. I reached there on Wednesday at around midnight. Christian was waiting for me as I told him that I will reach there by Taxi. I was so tired already and went to sleep.

On the next day, I went for a casual meeting on cybersecurity at a Media-Tech center as well as meeting with another acquaintance who is in the medical field. At St-Marie Media-Tech center, I got the opportunity to discuss Ansible, Automation technologies, Linux and TLS 1.3 for the IETF hackathons by the cyberstorm.mu team. It’s true that in Mauritius there is considerable effort to be made to do better Developers conferences, but, I seized this opportunity to build up the circle on the neighbor island which is also advanced in software development and Automation Engineering. The day was an enriching and successful one, however, time-consuming it was, I have been able to achieve my goal. I reached quite late at “Pension Cargo” and was so tired.

Pension Cargo
Pension Cargo

On Friday, I went for a nature walk near Pension Cargo. That place is still in its natural state with lots of exotic fruits.

Exotic fruits on the beach near Pension Cargo
Exotic fruits on the beach near Pension Cargo

In case you are a fan of the nature walk, I’m sure you would like it. It was indeed a nice time meeting up with several Linux user groups to discuss avenues of collaboration between Reunion and Mauritius. However, there are much more to see in Reunion island.

Random picture taken near Pension Cargo

IMG_2608
IMG_2608
IMG_2606
IMG_2591
IMG_2591
IMG_2591
IMG_2591
pensioncargo
IMG_2607
IMG_2607
IMG_2568
IMG_2568
IMG_2568
IMG_2568
IMG_2568
IMG_2568
IMG_2594
IMG_2596
IMG_2596
IMG_2596
IMG_2593
IMG_2566
IMG_2584
IMG_2573
IMG_2573
IMG_2573
IMG_2592
IMG_2592
IMG_2592
IMG_2606
IMG_2606
IMG_2606
IMG_2606
IMG_2607
IMG_2607
IMG_2567
Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...Loading image...

At “Pension Cargo”, you can never miss the Reunion beer made locally. I got it free too! This is something to never miss at all!

Beer made locally in Reunion island
Beer made locally in Reunion island

As regards to breakfast, lunch and dinner, its always nice and yummy whether it is chicken, duck, and seafood which is always accompanied by salads french style-made.

Lunch with chicken, Seafood, Potatoes and Salads
Lunch with chicken, Seafood, Potatoes, and Salads

In case, you are heading up to Reunion island or in transit, feel free to check out “Pension Cargo” which is always worth the price. As usual, I convinced Christian to join and create a Twitter account as a marketing strategy which worth for where it is located. Pension Cargo can seem to be easily booked on Booking.com and Airbnb. However, you can always contact the Christian and his family who are always there to welcome you with a smile and lots of beers and goodies.

The team at the bar
The team at the bar

I got the opportunity to visit Riviere des Roches which is located a few meters from where I live. I was told that fishermen build up walls on the river with the aim to narrow the passage and by using fishing nets to catch “bisik” fish known as the caviar of the Reunion island which is pretty expensive and delicious. Unfortunately, this can be a problem to the ecology of the island as depending on the curve being built with the wall and the increase of sea water levels might change drastically the width of the river. This is contributing to severe land erosion and inviting sharks close to the river. Obviously, some people in the vicinity are not happy at all. Its all a question of eating the famous caviar of Reunion island!

Walls built on the river
Walls built on the river

Walls built on the river to catch fish

IMG_2620
IMG_2621
IMG_2621
Loading image...Loading image...Loading image...

On the way to Mauritius, the weather was sunny and I seized the opportunity to make a video for my YouTube Channel. I already had so many landings from several countries. Why not add Mauritius to the playlist?


Installing the Networker Management Console (NMC) on CentOS 7

In the last article, we have seen how to install Dell EMC Networker on CentOS7. There have been some issues with dependencies. In this article, I will install the Networker Management Console on the same server. Prior before installing, we will see the services running when the networker services have been started. Then, I will compare if after installation of the NMC.

Before proceeding to installation, the packages that I will install is :

lgtonmc (Networker Management Console) – Gives you the ability to access the Management Interface or Management console to manage backups.

1. The services running before the installation is as indicated in the screenshot below:

2. In the previous article, I downloaded all the packages. From the directory, I have installed the NMC using the RPM command followed with the execution of the script /opt/lgtonmc/bin/nmc_config. You will be prompted to answer a few questions for the installation. I selected the default answer except to the creation of user for the PostgreSQL database.

3. Now, we can see a bunch of new services is running such as more Java processes and PostgreSQL.

4. Since we installed the NMC on the VM, we should be able to access the console on the same network on the port 9000. My VM is actually configured with the IPAddress 192.168.100.19 and by accessing it on port 9000 will now show me the console.

5. As you can notice on the screenshot above I don’t have Java Runtime enabled on the Mac. So I had to install and enable it. Follow the instructions for the installation by clicking on “Browser, OS, & JRE Requirements”.

6. Once installed and activated, you should be able to access the console by clicking on “Click here to start Management Console”. The prompt to enter username/password should then appear.

The default username is Administrator and password is the one you have set when installing Networker.

7. Follow the instructions to set up the database backup server, authentication server etc.. and at the end, you should be able to reach the console.


Installing EMC Dell Networker 9 on CentOS 7

Its been since some days, I attended a training on EMC Dell Networker 9 in Mauritius itself. Though not everything can be covered in the training such as the installation of the networker on Linux machines, I decided to install it myself on my lab.

photo credits: dell.com

For those who are not familiar with Networker 9 formerly called Legato NetWorker is an “enterprise-level data protection software product that unifies and automates backup to tape, disk-based, and flash-based storage media across physical and virtual environments for granular and disaster recovery.”. To install it, I created a Centos 7 minimal installation lab on virtual box, made an update and install some few packages such as vim, tcpdump, net-tools, traceroute, epel-repo, locate, atop, htop and wget. These are basic packages for my own use on the VM. It has nothing to do with the Networker installation.

To be able to download the necessary packages, it’s a prerequisite to register on the EMC Dell website first. Once authenticated, you can move on to the download section of the packages. Dell will provide you in a tar.gz all packages for Debian and RHEL as well. Even Avamar packages will be found there. So, you will need to install only the necessary packages. Follow the instructions below after registration on the Dell website and download of the packages and the links highlighted. Once the file has been downloaded and decompressed, you will notice several RPMs and DEBs inside. The one which will be needed for the networker installation are as follows:

  • lgtoclnt (Networker client) – Provides you the ability to perform file system backup and recovery options.

  • lgtoxtdclnt (Networker Extended client) – Provides additional feature support for NetWorker clients, such as snapshot backup support, command line utility support including server reporting and administration, cloning and staging support, and so on.

  • lgtonode (Networker Storage Node) – Provides features for the storage node which will control storage devices such as tape drives, disk devices, autochangers, and silos.

  • lgtoserv (Networker Server) – Provides you the web server of the Networker portal.

  • lgtoauthc (Networker Authentication Service) – Authentication layer used for the backup purpose.

  • lgtoman (Networker Manual) – Its important for the manual. However, it’s not a prerequisite.

Whilst installing these packages, you will notice dependencies problems. See the “Tips” section below for more information. I had to install the Glibc 32-bit package as some of the networker packages might depend on them.

Here is an idea what error message { libc.so.6 is needed by lgtoclnt-9.1.1.7-1.x86_64 } you may have while performing the installation.

This can be confirmed by a yum whatprovides libc.so.6 which is found inside glibc.i686 package

1. At this point, to continue on with the installation I made the following steps:

yum install glibc-2.17-260.el7.i686
rpm -ivh lgtoclnt*.rpm lgtoxtdclnt*.rpm lgtonode*.rpm lgtoserv*.rpm lgtoauth*.rpm lgtoman*.rpm

2. If you are installing the package one by one, you will need to install lgtoauth first before installing lgtoserv. After installation of lgtoauth, it will prompt you to launch the following script:

/opt/nsr/authc-server/scripts/authc_configure.sh

3. It will prompt you where to specify where you have installed the Java Runtime. At the time, I’m writing this article, I’m using Java Runtime 8 from the oracle.com website. Use the following syntax to download it from wget.

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn-pub/java/jdk/8u202-b08/1961070e4c9b4e26a04e7f5a083f551e/jre-8u202-linux-x64.rpm"

4. Once, downloaded and installed, java -version should provide you the runtime environment.

5. Now, you can launch the script /opt/nsr/authc-server/scripts/authc_configure.sh anew and it will prompt you to enter the key store and administrator passwords.

6. Once the installation is complete, you can now run the /etc/init.d/networker daemon and check the process running.

Tips:

  • The problem is that the GLIBC2.0 symbol is not provided by the x86-64 Libc on CentOS, but it is provided by the 32-bit i686 package. There is no real dependency of the EMC NetWorker 9.1 package on the 32-bit library, but this is probably a false dependency RPM problem. So it is necessary to download the following 32-bit packages from the CentOS website and install them.

  • If you have installed the JAVA elsewhere, you will need to specify the path launch executing the script /opt/nsr/authc-server/scripts/authc_configure.sh

  • The installation logs are found at /opt/nsr/authc-server/logs/install.log.

  • For testing purpose, I deactivated firewalld and disable SELinux.