As long as I understood it is because of privilege configuration with the Docker and running a container. When we login to the OS, it seems we are root
but infact we do not have the right root
permission. And here is a simple try:
root[0]docker:~# docker run -it archlinux:latest bash
[root@c565c90fdb7f /]# pacman
error: failed to initialize alpm library
(could not find or read directory: /var/lib/pacman/)
[root@c565c90fdb7f /]# exit
exit
but if we give the right root permission when we login to the container then it is okay.
root[0]docker:~# docker run -it --privileged=true archlinux:latest bash
[root@0d95575abec6 /]# dir
bin boot dev etc home lib lib64 mnt opt proc root run sbin srv sys tmp usr var
[root@0d95575abec6 /]# pacman
warning: database file for 'core' does not exist (use '-Sy' to download)
warning: database file for 'extra' does not exist (use '-Sy' to download)
warning: database file for 'community' does not exist (use '-Sy' to download)
error: no operation specified (use -h for help)
[root@0d95575abec6 /]# pacman -Sy
:: Synchronizing package databases...
core 131.2 KiB 10.7 MiB/s 00:00 [####################################################################################] 100%
extra 1654.4 KiB 101 MiB/s 00:00 [####################################################################################] 100%
community 5.4 MiB 270 MiB/s 00:00 [####################################################################################] 100%
[root@0d95575abec6 /]# exit
exit
So for login to Arch Linux
this options --privileged=true
should be used whereas for Debian
, Alpine
, Ubunut
it seems we do not need it.
Has been tested on:
cat /etc/os-release
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://www.archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
LOGO=archlinux
and
pacman -V
.--. Pacman v5.2.2 - libalpm v12.0.2
/ _.-' .-. .-. .-. Copyright (C) 2006-2020 Pacman Development Team
\ '-. '-' '-' '-' Copyright (C) 2002-2006 Judd Vinet
'--'
This program may be freely redistributed under
the terms of the GNU General Public License.
and Docker
docker -v
Docker version 19.03.6, build 369ce74a3c