Home > Enterprise >  apt-get install Python3 in fresh Ubuntu Docker Image results in Error 13 Permission Denied
apt-get install Python3 in fresh Ubuntu Docker Image results in Error 13 Permission Denied

Time:01-20

Update2

Okay, I've rebuilt the Ubuntu server from scratch and the problem still exists. This is how I am doing it.

  1. Create a virtual machine in ESXI with two disk volumes. The first is 50GB and the second is 250GB.
  2. Run the Ubuntu 22.04 LTS install
  3. Create a static IP address
  4. Create two LVM volumes, the 50GB is root and the 350GB is mounted as /var
  5. Select Docker and Prometheus to be installed along with Ubuntu
  6. Let the install run to completion.
  7. Unmount the CD rom when finished and reboot Ubuntu
  8. Login and then sudo bash
  9. docker pull ubuntu
  10. docker run -it ubuntu
  11. apt-get update
  12. apt-get install -y python3

You should get the error

I am running a new/fresh Ubuntu Docker image on a 22.04 LTS Ubuntu server instance. Docker was installed during the Ubuntu 22.04 LTS install. It is a new Ubuntu 22.04 LTS install.

I'm using docker version 20.10.17, build 100c70180f.

I am having trouble getting python3 installed in the running docker container.

To start off, I get the Ubuntu image running in a container:

docker run -ti ubuntu

In the image I run (as the root user)

apt update

Then I run

apt install python3

The installation fails with:

root@6bfb4be344d6:/# apt-get install python3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libexpat1 libmpdec3 libpython3-stdlib libpython3.10-minimal libpython3.10-stdlib libreadline8 libsqlite3-0 media-types python3-minimal python3.10 python3.10-minimal readline-common
Suggested packages:
  python3-doc python3-tk python3-venv python3.10-venv python3.10-doc binutils binfmt-support readline-doc
The following NEW packages will be installed:
  libexpat1 libmpdec3 libpython3-stdlib libpython3.10-minimal libpython3.10-stdlib libreadline8 libsqlite3-0 media-types python3 python3-minimal python3.10 python3.10-minimal readline-common
0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
Need to get 6494 kB of archives.
After this operation, 23.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpython3.10-minimal amd64 3.10.6-1~22.04.2 [810 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libexpat1 amd64 2.4.7-1ubuntu0.2 [91.0 kB]                                                                                                              
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 python3.10-minimal amd64 3.10.6-1~22.04.2 [2251 kB]                                                                                                     
Get:4 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 python3-minimal amd64 3.10.6-1~22.04 [24.3 kB]                                                                                                          
Get:5 http://archive.ubuntu.com/ubuntu jammy/main amd64 media-types all 7.0.0 [25.5 kB]                                                                                                                                 
Get:6 http://archive.ubuntu.com/ubuntu jammy/main amd64 libmpdec3 amd64 2.5.1-2build2 [86.8 kB]                                                                                                                         
Get:7 http://archive.ubuntu.com/ubuntu jammy/main amd64 readline-common all 8.1.2-1 [53.5 kB]                                                                                                                           
Get:8 http://archive.ubuntu.com/ubuntu jammy/main amd64 libreadline8 amd64 8.1.2-1 [153 kB]                                                                                                                             
Get:9 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libsqlite3-0 amd64 3.37.2-2ubuntu0.1 [641 kB]                                                                                                           
Get:10 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpython3.10-stdlib amd64 3.10.6-1~22.04.2 [1832 kB]                                                                                                  
Get:11 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 python3.10 amd64 3.10.6-1~22.04.2 [497 kB]                                                                                                             
Get:12 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpython3-stdlib amd64 3.10.6-1~22.04 [6910 B]                                                                                                        
Get:13 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 python3 amd64 3.10.6-1~22.04 [22.8 kB]                                                                                                                 
Fetched 6494 kB in 14s (478 kB/s)                                                                                                                                                                                       
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libpython3.10-minimal:amd64.
(Reading database ... 4395 files and directories currently installed.)
Preparing to unpack .../libpython3.10-minimal_3.10.6-1~22.04.2_amd64.deb ...
Unpacking libpython3.10-minimal:amd64 (3.10.6-1~22.04.2) ...
Selecting previously unselected package libexpat1:amd64.
Preparing to unpack .../libexpat1_2.4.7-1ubuntu0.2_amd64.deb ...
Unpacking libexpat1:amd64 (2.4.7-1ubuntu0.2) ...
Selecting previously unselected package python3.10-minimal.
Preparing to unpack .../python3.10-minimal_3.10.6-1~22.04.2_amd64.deb ...
Unpacking python3.10-minimal (3.10.6-1~22.04.2) ...
Setting up libpython3.10-minimal:amd64 (3.10.6-1~22.04.2) ...
Setting up libexpat1:amd64 (2.4.7-1ubuntu0.2) ...
Setting up python3.10-minimal (3.10.6-1~22.04.2) ...
[Errno 13] Permission denied: '/usr/lib/python3.10/__pycache__/__future__.cpython-310.pyc.139849676216832'dpkg: error processing package python3.10-minimal (--configure):
 installed python3.10-minimal package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 python3.10-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)

Looking into the /user/lib/python3.10/__pychache__/ all of the files in the directory are -rw-r--r--

How can the install complain of Permission denied when running as root and the user permissions for every file in the directory is rw?

Update

I upgraded to docker 20.10.22 build 3a2c30b but still am encountering this issue.

CodePudding user response:

I reinstalled Ubuntu 22.04 and this time did not select Docker as one of the packages installed along with Ubuntu. I installed Docker manually after the Ubuntu install completed and after a reboot.

Now it works fine.

I reinstalled ubuntu 22.04 again, just to make sure I could reproduce the problem and indeed, if I select Docker to be installed with Ubuntu, the problem resurfaces.

  • Related