0

I've a RHEL host with docker installed, it has default Py 2.7. My python scripts needs a bit more modules which I can't install due to lack of sudo access & moreover, I dont want to screw up with the default Py which is needed for host to function.

Now, I am trying to get a python in docker container where I get to add few modules do the needfull.

Issue - docker installed RHEL is not connected to internet and cant be connected as well

The laptop i have doesnt have the docker either and I can't install docker here (no admin acccess) to create the docker image and copy them to RHEL host

I was hoping if docker image with python can be downloaded from Internet I might be able to use that as is!,

Any pointers in any approprite direction would be appreciated.

what have I done - tried searching for the python images, been through the dockers documentation to create the image.

Apologies if the above question sounds silly, I am getting better with time on docker :)

2
  • are you able to do docker pull? Commented Dec 2, 2018 at 12:34
  • Yes, I am able to run docker pull... Commented Dec 8, 2018 at 13:20

2 Answers 2

1

If your environment is restricted enough that you can't use sudo to install packages, you won't be able to use Docker: if you can run any docker run command at all you can trivially get unrestricted root access on the host.

My python scripts needs a bit more modules which I can't install due to lack of sudo access & moreover, I dont want to screw up with the default Py which is needed for host to function.

That sounds like a perfect use for a virtual environment: it gives you an isolated local package tree that you can install into as an unprivileged user and doesn't interfere with the system Python. For Python 2 you need a separate tool for it, with a couple of steps to install:

export PYTHONUSERBASE=$HOME
pip install --user virtualenv
~/bin/virtualenv vpy
. vpy/bin/activate

pip install ... # installs into vpy/lib/python2.7/site-packages
Sign up to request clarification or add additional context in comments.

Comments

1

you can create a docker image on any standalone machine and push the final required image to docker registry ( docker hub ). Then in your laptop you can pull that image and start working :)

Below are some key commands that will be required for the same.

  • To create a image, you will need to create a Dockerfile with all the packages installed
  • Or you can also do sudo docker run -it ubuntu:16.04 then install python and other packages as required.
  • then sudo docker commit container_id name
  • sudo docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
  • sudo docker push IMAGE_NAME

Then you pull this image in your laptop and start working.

You can refer to this link for more docker commands https://github.com/akasranjan005/docker-k8s/blob/master/docker/basic-commands.md

Hope this helps. Thanks

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.