I've been trying to use docker run to launch a previously pulled Tensorflow image.

Once I've done that, is there a way to use run along with a tag to include all of my apt packages?

I tried using:

docker run --rm --runtime=nvidia --privileged -it --env="DISPLAY" --env="PATH" --mount type=bind,source="$(pwd)",target=/matthew -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev/bus/usb:/dev/bus/usb --network="host" tensorflow/tensorflow:latest-gpu-jupyter bash

I also tried --env=$PATH

This doesn't seem to work to include the apt packages.

I suppose the alternative is to use Docker From:Ubuntu as a parent image?

Any suggestions much appreciated!

  • just to clarify, you wan to run apt command inside the container from the system? – AtomiX84 May 2 '19 at 7:01
  • I just want to be able to use apt packages inside the container such as gedit or nano, etc. – Matthew Weems May 2 '19 at 8:30
  • All of TensorFlow's images are based on Ubuntu 16.04, so you should be able to use apt inside the image. You should create your own Dockerfile with FROM tensorflow/tensorflow:latest-gpu-jupyter and RUN apt update && apt install .... – pLumo May 2 '19 at 8:35
  • I just did not want to install a second copy of apt packages. Was trying to find an alternative. I don't have unlimited storage. :) – Matthew Weems May 2 '19 at 8:49
  • Have you tried instead of only bash. you can use apt update && apt install .... && bash, – Aditya Pawaskar May 2 '19 at 8:57

If you want to add additional packages in a docker image, you create a Dockerfile:

FROM ubuntu
RUN apt-get install <whatever>

(it is recommended to install as much as you can in one call to RUN apt-get install, in other words, avoid using one apt-get per package)

You then create a new image using

docker build -t ubuntu-improved .

(. means "using the current directory as the source", Dockerfile is a reserved name for the container descriptions file, if you use another name, see the -f option). You can then run your image with

docker run ubuntu-improved

However, you normally don't need to install X and editors in the container (not even sure that X will run...). If you need to edit files used by the container, you use a bind-mount to share the file between host and container:

docker run -v /file/on/host:/file/in/container ubuntu-improved

Then you edit /file/on/host with your usual tools. The file can also be a directory.

| improve this answer | |
  • also you can tag your own created imange docker build -t ubuntu-improved:tag – AtomiX84 May 3 '19 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.