0

I have this following image:

REPOSITORY               TAG         IMAGE ID       CREATED       SIZE
nvcr.io/nvidia/pytorch   18.04-py3   c3555fec4fe6   3 years ago   5.9GB

The goal is to use Ubuntu 18.04 with CUDA 10.2. Now I want to create a container with this image. How can I do that? The guides online didn't make much sense to me as I'm pretty new to docker.

2 Answers 2

1

Depending on what you want to do, there are a lot of options you can pass in to docker, but if you just want to run the code in the container as written:

docker run nvcr.io/nvidia/pytorch:18.04-py3

or

docker run c3555fec4fe6

or even

docker run c3

you can give your docker images a more reasonable name with

docker image tag nvcr.io/nvidia/pytorch:18.04-py3 pytorch

and run that with

docker run pytorch


see

  • man docker-run

  • man docker-image-tag

and https://docs.docker.com/engine/reference/commandline/run/

6
  • I did docker image tag nvcr.io/nvidia/pytorch:18.04-py3 pytorch and then tried to do sudo docker run pytorch but its giving me docker: Error response from daemon: mkdir /var/lib/docker/containers/22346b8352726ee06780791c3ee37c138b8c4b3d600225502266916e57902c56: no such file or directory.
    – oo92
    Mar 11 at 14:53
  • What's the linux distribution you're running docker on? Could be selinux or apparmor preventing dockerd from doing its work. You could manually mkdir sudo mkdir -p /var/lib/docker/containers but I think the docker installer should have taken care of that. I've read people with those kinds of errors get 'em fixed with a re-install yum reinstall docker or apt-get --reinstall install docker
    – Peter Turner
    Mar 11 at 15:21
  • I'm running Ubuntu 21.10
    – oo92
    Mar 11 at 15:54
  • OK then probably apparmor, you can test and see if it works with apparmor turned off "systemctl stop apparmor" then I'd ask a followup question (this is docker-weeds specific, not devops , I'd ask on askubuntu.com or unix.stackexchange.com) to see what you're supposed to do at that point.
    – Peter Turner
    Mar 11 at 15:59
  • I already have /var/lib/docker/containers. I think docker is just not turning this image into a container..
    – oo92
    Mar 11 at 16:27
1

This would be the multi-layer approach in docker containers...

#Create the base OS image
FROM python:3 AS base

#Update the OS ubuntu image
RUN apt-get -y update

#Install packages
RUN apt-get -y install firefox \
&& apt-get -y install vim

#Create another image layer on top of base to install requirements
FROM base AS requirements

#Install the requirements
RUN pip3 install -r requirements.txt

#Create an intermediate image layer for testing purpose
FROM requirements as test

#Create the build context
COPY /usr/src/my-app /desktop/my-app

#Test the final app
CMD ["python3", "index.py"]

Take a look at this: https://www.geeksforgeeks.org/how-to-combine-multiple-base-images-using-single-dockerfile/

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.