How to gain root access to an existing docker container?
Solution is to use exec as:
root@doge:~# 
root@doge:~# docker run -ti     -d     --name basexhttp     --publish 1984:1984     --publish 8984:8984     --volume &quot;$(pwd)/basex/data&quot;:/srv/basex/data     basex/basexhttp:latest
5699af1dc04aa9c78066222e4b0b8e5621aa2ab9dd2bd46bcd87c6a0377c1960
root@doge:~# 
root@doge:~# docker container list
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                                                      NAMES
5699af1dc04a        basex/basexhttp:latest   &quot;/usr/local/bin/mvn-…&quot;   33 seconds ago      Up 30 seconds       0.0.0.0:1984-&gt;1984/tcp, 0.0.0.0:8984-&gt;8984/tcp, 8985/tcp   basexhttp
root@doge:~# 
root@doge:~# docker exec -ti --user root basexhttp bash
bash-4.4# 
bash-4.4# whoami
root
bash-4.4# 
bash-4.4# su basex
~ $ 
~ $ whoami
basex
~ $ 
~ $ exit
bash-4.4# exit
exit
root@doge:~# 
root@doge:~# docker container list
CONTAINER ID        IMAGE                    COMMAND                  CREATED              STATUS              PORTS                                                      NAMES
5699af1dc04a        basex/basexhttp:latest   &quot;/usr/local/bin/mvn-…&quot;   About a minute ago   Up About a minute   0.0.0.0:1984-&gt;1984/tcp, 0.0.0.0:8984-&gt;8984/tcp, 8985/tcp   basexhttp
root@doge:~# 
root@doge:~# docker ps -a
CONTAINER ID        IMAGE                    COMMAND                  CREATED              STATUS              PORTS                                                      NAMES
5699af1dc04a        basex/basexhttp:latest   &quot;/usr/local/bin/mvn-…&quot;   About a minute ago   Up About a minute   0.0.0.0:1984-&gt;1984/tcp, 0.0.0.0:8984-&gt;8984/tcp, 8985/tcp   basexhttp
root@doge:~#