Cli switch between rootless and root mode

hello community,

i just accounted that my dev system and my production setup had a slight difference:

  • dev was in root mode
  • produciton in rootless mode

both running debian/ubuntu based systems…

that did catch me with my file-owner setups in bind mounts…
(luckily found this post)

so i decided to switch my dev setup to rootless mode too.

as the two modes use different locations to store things i have to rebuild things…
that is all fine -
but currently iam running out of disc space - so i need to first clean up the old images & containers from the root full builds…

therefore i need to switch back to the root full setup.
what is the best way to switch between these to setups?!

or is it save to just remove everything in /var/lib/docker ?

all tips and hints are welcome :slight_smile:

sunny greetings
stefan

Rootless mode

docker context use rootless

Rootful mode

docker context use default

List all contexts

docker context list
1 Like

thansk @rimelek!

that partly worked:

stefan$ docker context ls
NAME        DESCRIPTION                               DOCKER ENDPOINT                     ERROR
default *   Current DOCKER_HOST based configuration   unix:///var/run/docker.sock         
rootless    Rootless mode                             unix:///run/user/1000/docker.sock   
stefan$ docker context use rootless 
rootless
Current context is now "rootless"
stefan$ docker image ls
REPOSITORY                   TAG          IMAGE ID       CREATED         SIZE
xxx/myapp-prod   0.14.0-WIP   679132d86eb6   11 hours ago    5.2GB
xxx/myapp-prod   latest       679132d86eb6   11 hours ago    5.2GB
phpmyadmin                   latest       c6d2e5105bad   2 days ago      562MB
mariadb                      10.3         1172e50de434   13 months ago   369MB
stefan$ docker context use default 
default
Current context is now "default"
stefan$ docker image ls
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

i had - mad a lot of sens -
to restart the root docker deamon:

stefan$ sudo systemctl restart docker

after this it worked :

stefan$ docker image ls
REPOSITORY                       TAG                IMAGE ID       CREATED         SIZE
xxx/myapp-prod   0.14.0-WIP   0656edc975e5   14 hours ago    5.2GB
xxx/myapp-prod   latest       0656edc975e5   14 hours ago    5.2GB
nginxproxy/nginx-proxy           latest             e3c8f7fa319b   2 weeks ago     205MB
alpine                           latest             1d34ffeaf190   3 weeks ago     7.79MB
nginx                            latest             e784f4560448   6 weeks ago     188MB
nginxproxy/nginx-proxy           1.5                fee856412c4b   6 weeks ago     205MB
phpmyadmin                       latest             87501b683e84   7 weeks ago     562MB
mariadb                          10.3               1172e50de434   13 months ago   369MB
php                              7.4-apache         20a3732f422b   19 months ago   453MB
jwilder/whoami                   latest             89be8564e650   6 years ago     10.1MB
1 Like