Docker usage cheatsheet

My docker usage cheat sheet is  a simplified version on this fantastic one on GitHub. I followed the structure I used for my apparently popular Slurm user cheatsheet.

What it does Command
List active dockers docker ps
List all dockers docker ps -a
Show all docker stats (like top) docker stats –all
Stop a docker docker stop dockername
Start a docker docker start dockername
Remove a stopped docker docker rm dockername
Remove a docker (even if it’s running) docker rm -f dockername
Show docker logs  docker logs dockername
List downloaded images  docker images
Remove an image  docker rmi imagename
Show docker server information  docker info
Run a docker, name it pepe  docker run –name pepe imagename
Run a docker in the background  docker run -d imagename
Run a docker over the IP  docker run -p
Run a docker sharing a folder with it  docker run -v $HOSTPATH:$DOCKPATH
Get a shell in the docker, if possible  docker exec -it dockername /bin/bash
 Run a docker sharing 50% of CPU  docker run -ti -c 512 dockername
 Run a docker over cpus 0,4,6 only docker run -ti –cputest-cpus=0,4,6 dockername
 Run a docker that can use 300M memory and 300M swap memory (total 600M) docker run -ti -m 3000M dockername

I didn’t try yet to set up memory constrains. In principle I will use my dockers for my services, like my munin server. But who knows, I’m open to suggestions and I may end up making dockers for all my software 🙂


A docker webserver on CentOS 7

I will base my docker on the katacoda online tutorial. I will suppose you have the docker installed on a CentOS 7 system. We want to run a container that will be visible in our intranet, based on a nginx image. First we create a Dockerfile. Mine is looking like this:

Dockers/nginx ## > more Dockerfile 
FROM nginx:alpine
COPY static-html-directory /usr/share/nginx/html

Then we build an image, that we will call webserver-image:v1

Dockers/nginx ## > docker build -t webserver-image:v1 .
Sending build context to Docker daemon 4.608 kB
Step 1 : FROM nginx:alpine
Trying to pull repository ... 
alpine: Pulling from
ff3a5c916c92: Pull complete 
b4f3ef22ce5b: Pull complete 
8a6541d11dc3: Pull complete 
7e869e2dcf68: Pull complete 
Digest: sha256:48947591194ac5a9dce1e110f9198
 ---> 537527661905
Step 2 : COPY static-html-directory /usr/share/nginx/html
 ---> 933ca1ba4600
Removing intermediate container 53c4cc3ea6a3
Successfully built 933ca1ba4600

Now we will create a VLAN for the IP of the docker. On a console, I open the nm-connection-manager. I click on Add –> connection type VLAN, give it a name, choose an (online) working interface, give a VLAN id (a number) and a VLAN interface name. Then go to the IPv4 settings and give it an IP on the same subnet than the main machine. Basically, what I do is fill up that the same way the main interface +1 on the IP address (if the IP is free, of course). Let’s say our IP is, then the VLAN IP will be Be aware of the netmask and route of your VLAN! You can test the VLAN is online by typing ifconfig -a, and ping In my case, after a network restart, I’m now able to ping the address from another computer on my subnet.

Time to run the docker! We do so via one script, but in principle, there’s no difference if you simply copy and paste this on your command line:

docker run --name webserver \
 -v /var/www/html/:/usr/share/nginx/html/ \
 -d -p \

A little bit of info, in case it is not obvious: –name is the docker name, -v is linking /var/www/html with the nginx html folder, -d is to run the docker in the backround, -p is to give the port (+ the IP address) and the last parameter is the image used for the docker. We are ready to point a browser to You should see this:


Even from the remote client on the same intranet. Now, if you do chmod 755 on /var/www/html/, copy some index.html and stop and start the container again:

docker stop webserver
docker start webserver

you should see your index.html. We have our web server. You can check this post to know more about how to share data between the docker container and the host. Done!

Create, run, destroy a docker no dockerfile on CentOS 7

Following up what I previously wrote here, I will now create an on-the-fly docker (??)  check what is there, and destroy it.  That is to say, without a dockerfile, but using a command. I use the instructions on the official httpd docker repository, and later I will polish the result.

/Docker/docker-container ## > docker run -dit --name \
my-apache-app -p 8080:80 \
-v "$PWD":/usr/local/apache2/htdocs/ httpd:2.4
Unable to find image 'httpd:2.4' locally
Trying to pull repository ... 
2.4: Pulling from
4176fe04cefe: Pull complete 
d6c01cf91b98: Pull complete 
b7066921647a: Pull complete 
643378aaba88: Pull complete 
3c51f6dc6a3b: Pull complete 
4f25e420c4cc: Pull complete 
ccdbe37da15c: Pull complete 
Digest: sha256:6e61d60e4142ea44e8e69b22f1e739d1e

My command is in bold. Be aware that, as usual, I cleaned up the output a little. To pull the docker (the technical word) takes in my case around 2 minutes. Let’s see what we got.

/Docker/docker-container ## > docker info
Containers: 1
 Running: 1
 Paused: 0
 Stopped: 1
Images: 9
... and a lot of more down here..

Right. It looks like we have a lot of images. Let’s list them.

/Docker/docker-container ## > docker images
REPOSITORY        TAG      IMAGE ID      CREATED        SIZE   2.4      01154c38b473  6 days ago     177.4 MB
friendlyhello     latest   e87fd1aa91b7  2 weeks ago    148.3 MB  2.7-slim 4fd30fc83117  10 weeks ago   138.5 MB

That’s a little misleading. I’m not sure the httpd image is my image, but let’s ignore it. Now I want to stop the container that is running, and delete it. We do stop, and info.

/Docker/docker-container ## > docker stop my-apache-app
/Docker/docker-container ## > docker info
Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 9
...a lot of stuff here..

So that’s the way to stop a docker. How can I delete it? Again, we simply try a command (it is not delete) and check the result.

/Docker/docker-container ## > docker rm my-apache-app
root@xleginon /Docker/docker-container ## > docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 9
...a lot of stuff here...

Mission accomplished. Docker deleted! Next step, to polish my docker definition.

“Could not start D-bus. Can you call qdbus” error after KDE update CentOS 7

Scenario: The system needs to be updated. Before that, an AD user can log in no problem with kerberos credentials, the client is online and all the systems are up and running. Then I do yum update, no special tags attached. I have like 1049 packages to update or erase, but I go ahead. After I’m done, I reboot.

Symptoms: We have two desktops, GNOME and KDE, managed by the Gnome Desktop Manager (GDM) service. Another AD user can log in on both desktops (gnome and kde) but “this AD user” can log in only on Gnome, when trying on KDE, he gets a pop-up window with the message:

Could not connect to D-Bus. Can you call qdbus? 

You can only click OK. If you do so, the gdm login screen comes back. Trying again will bring you back to the same point.

Solution: As root, I call the qdbus. In fact, I restart it.

systemctl restart dbus.service

It doesn’t work. Following this ubuntu thread I go for having a look on the startkde script, placed on /usr/bin/. I edit my file, but it doesn’t look like any specific dbus is called (there’s nothing like qdbus=QT_SELECT=qt4 qdbus).  I managed to change the error message, but I didn’t fix the problem. What could this be?

I delete the /home/user/.kde folder for the user, but it is still not “regenerated”. I copy mine, that seems to work, with a similar result. Still I get the popup window. On this forum, they say it’s Qt-related. So I try updating Qt by typing this:

yum install PyQt4.x86_64 poppler-qt4.x86_64 poppler-qt4-devel.x86_64 PyQt4-devel.x86_64 avahi-qt4.x86_64 avahi-qt4-devel.x86_64

Unfortunately, still the user get the message. What could it be? Speaking with the user, it turns out he WAS installing his own Qt flavor.  On his bashrc I find the next:

export LD_LIBRARY_PATH=/home/user/Programs/qt/lib:\

What if we comment this one? Shall we try that out? YESSSS. KDE is back. I understand that the system was “looking” for qt libraries in a certain order, and it was finding the “user” qt libraries instead of the “system” ones. And the user libraries were not capable of giving KDE what it wanted. That was, if I can say it like that, a good qdbus. Always rely on the public transport 😀 😀 😀

Removing a kernel with yum on CentOS 7

E molto facile e divertente. But I tend to forget the commands. First we list the existing kernels:

#> yum list kernel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base:
 * centosplus:
 * epel:
 * epel-testing:
 * extras:
 * updates:
Installed Packages
kernel.x86_64   3.10.0-514.6.2.el7  @updates
kernel.x86_64   3.10.0-514.10.2.el7 @updates
kernel.x86_64   3.10.0-514.16.1.el7 @updates
kernel.x86_64   3.10.0-693.5.2.el7  @updates
kernel.x86_64   3.10.0-693.11.1.el7 @updates
Available Packages
kernel.x86_64 3.10.0-693.17.1.el7 updates

The installed kernel are in bold, the current kernel appears underlined. Then we write yum remove kernel-KERNEL-DETAIL. For example:

yum remove kernel-3.10.0-693.11.1.el7
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-693.11.1.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

 Package Arch Version Repository Size
 kernel x86_64 3.10.0-693.11.1.el7 @updates 59 M

Transaction Summary
Remove 1 Package

Installed size: 59 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Erasing : kernel-3.10.0-693.11.1.el7.x86_64 1/1 
 Verifying : kernel-3.10.0-693.11.1.el7.x86_64 1/1

 kernel.x86_64 0:3.10.0-693.11.1.el7


And done. Why am I doing it? Why should I clean up old kernels? Well, there’s the long and the short explanation. The long explanation I will not write, the short one, the system will not go to the next kernel unless there’s space on the boot partition for it. If your boot partition is small, you will not be able to have more than one kernel.

Maybe you have noticed also that I removed the newest kernel that was already installed (the 11.1). You need to do that from time to time, since new kernels come with new problems, and not all the things work on a new kernel out of the box.  In my case, the GPFS mounting was not working. Be aware and don’t forget testing everything!

Windows 10 enable ping and AD login

It is done similar to Windows 7. Just to save your time, in my case it didn’t work enabling some of the firewall rules:


  • Click Advanced Settings on the left.
  • From the left pane of the resulting window, click Inbound Rules.
  • In the right pane, find the rules titled File and Printer Sharing (Echo Request – ICMPv4-In).
  • Right-click each rule and choose Enable Rule.


as described in this post. I also tried in addition enabling the all the “File and Printer Sharing” rules, without luck. I write it in no just for the documentation.

I managed to get my ping by manually creating two new firewall rules, one for ICMPv4, the other for ICMPv6. You have a more detailed solution, with screen shots, on this how-to-geek post about. Why I didn’t do it using the command prompt, as suggested first on the top of the post? Let’s say, I’m reluctant to touch the command prompt in Windows. It took me quite some time to get my new Windows 10 license, and I don’t want to screw it up by mistyping on the command prompt. Or being more specific, I don’t want to screw up how my Windows 10 system speak up with my switch, since I don’t have control over it. I’m just a middle man here, with limited rights.

Now, I hook it up to our domain to allow Active Directory users to log in. And I can, but the user sign in in with a temporary profile. He or she will get this nasty message:


You can fix that up following this solution. I’m not going to unless I’m asked to. I have a lot of users, and anyway the home folder is mounted if you log in, despite of the scary message. I will check if I can find an elegant way to avoid the message to pop up, once for all. Have a nice day…

Checks (if) in bash

More bash notes. This information is present everywhere, but this one is useful for me. On this post, the “if”, or “if” used for checks. In a raw:

### check that INPUT folder is there
if [ ! -d "$INPUT" ]; then
   echo " INPUT folder missing or not readable" 
   exit 0;
### check that file SCRIPT is there
if [ ! -f "$SCRIPT" ]; then
   echo " file SCRIPT missing or not readable" 
   exit 0;
### check that VAR is not empty 
if [[ ! $VAR ]]; then
 echo " VAR missing or not readable" 
 exit 0;

Now you can check “with if” if the file is there, if the directory is there and if your variable is empty. Otherwise the script ends (exit 0). You can see the power of these lines. Soon, if I can collect meaningful examples, I will write about flows (while, case…). And in the faaaar future, I will continue with similar post about the other programming languages…if only I could find my notes…