Monday, September 6, 2021

Docker - Attach Volume to a running container | Map a directory of host with the container

When you run a container, you attach volume with the run command as docker does not provide any option to attach a volume for a running container.

Generally you use parameter '-v' with run command to map the host directory with the container

docker run -it -p 80:80 -p 3306:3306 -v /var/www/html:/var/www/html ubuntu:18.04 /bin/bash

You want to attach the volume because you want to access the contents of host directory in the container.

If you want to attach a volume or multiple volumes to a running container, here is the solution.

1. Stop the container and cd into the container directory

cd /var/lib/docker/containers/d260db74672bf96c07536835229b1b3609c74f24ba54e4c4d0e314b24d01ae19

(long string is container id)

2. Edit files configv2.json and hostconfig.json


3. Add your extra require volume settings in these two files
hostconfig.json

{"Binds":["/var/www/html:/var/www/html","/opt:/opt"],
configv2.json
"MountPoints":{"/var/www/html":{"Source":"/var/www/html","Destination":"/var/www/html","RW":true,"Name":"","Driver":"","Type":"bind","Propagation":"rprivate","Spec":{"Type":"bind","Source":"/opt/lampp/htdocs/InvoicePlane","Target":"/var/www/html/InvoicePlane"},"SkipMountpointCreation":false},"/opt":{"Source":"/opt","Destination":"/opt","RW":true,"Name":"","Driver":"","Type":"bind","Propagation":"rprivate","Spec":{"Type":"bind","Source":"/opt","Target":"/opt"},"SkipMountpointCreation":false}},

Here we have mounted two host directories inside the container. /var/www/html and /opt of host is visible in the same directory of the container.


4. Restart Docker, start container and log into it. Host Directory content should be available in the container.

Using this method you can connect single volume or multiple volumes.

Note : You can map one directory of host in the other directory of container. Example you can map /var/www/html of host inside /opt/lampp/htdocs of docker container or vice versa.
 

You can see practical example in this video to understand the steps better.


 

 

Tuesday, August 10, 2021

Run Skype as a root user in Linux Ubuntu CentOS Fedora

Skype is not working for root in ubuntu

Now Skype does not work for root user in Linux.

In recent versions, they have also removed the option --no-sandbox for root user.

Here is the solution to open Skype as root user in Linux without any security loophole and without --no-sandbox

Once you have installed latest version of Skypeforlinux in your Ubuntu, CentOS, Fedora or any other distribution, now follow the tutorial to open the skype as a root user in Linux.

 


Run Skype version 60.0+ on Centos 7, Centos 8, Ubuntu 20.04 or Ubuntu 18.04 as a root


Run Skype version 70.0+ on Centos 7, Centos 8, Ubuntu 20.04 or Ubuntu 18.04 as a root

Skype crashes when I run it as a root user in Linux | skypeforlinux not launch anymore | Skype for linux as a root user in Ubuntu | Open Skypeforlinux as a root user | skype not running as root user in linux | skype now working with sudo


Saturday, August 7, 2021

Django Migration Error - '%s=%s' % (k, v) for k, v in params.items(),

Django Migration Error :

  File "/home/pavi/ldap/lib/python3.8/site-packages/django/contrib/admin/__init__.py", line 4, in <module>
    from django.contrib.admin.filters import (
  File "/home/pavi/ldap/lib/python3.8/site-packages/django/contrib/admin/filters.py", line 10, in <module>
    from django.contrib.admin.options import IncorrectLookupParameters
  File "/home/pavi/ldap/lib/python3.8/site-packages/django/contrib/admin/options.py", line 12, in <module>
    from django.contrib.admin import helpers, widgets
  File "/home/pavi/ldap/lib/python3.8/site-packages/django/contrib/admin/widgets.py", line 151
    '%s=%s' % (k, v) for k, v in params.items(),

Solution :

Update file at line number 151

Add the Parenthesis
  File "/home/pavi/ldap/lib/python3.8/site-packages/django/contrib/admin/widgets.py", line 151

('%s=%s' % (k, v) for k, v in params.items()),