Docker Community Forums

Share and learn in the Docker community.

How do I install Python in a Docker container when I have no Internet access?


(Mike812) #1

Part 1
I have CentOS with no Internet access. I have a docker container based on Ubuntu. I want to install Python inside the Docker container. I downloaded some .deb files for installing Python 2.7. I tried to install them with apt-get. But those commands required Internet access.

I used dpkg -i to install the packages. I use dpkg -i libpython2.7-stdlib_2.7.6_8_amd64.deb. I then followed up with apt-get install -f. I am prompted with a yes/no question about extra packages. I chose Y. I then received an error about not being able to reach some URLs. This isn’t surprising because the underlying server cannot get to the Internet. The URLs in the error message refer to python2.7-minimal_2.7.5-5ubuntu3_amd64.deb among others. I specifically have this .deb file. But when I try to install it, I get an error about an unmet dependency python2.7-minimal. I am well aware that this was not installed. I want it installed.

How do I install python2.7-minimal_2.7.6-amd64.deb in Docker?

Part 2
I tried to workaround the problem that I don’t know how to solve. I obtained Python-2.7.11.tar.xz. It is 12 MB. In the Docker container, tried this:

tar xvf Python-2.7.11.tar.xz

But I get “tar (child): xz: connect exec: No such file or directory”

I verified the file exists. In fact, when I type the command “tar xvf Python2.7” I can press tab to complete the full name of the file. Is there a standalone file or other offline method for installing Python?

Final request:
Ideally I can get assistance for both parts even though only one needs to work.