Answers: <p>This would be the multi-layer approach in docker containers...</p>
  <pre><code>#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 \
  &amp;&amp; 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 [&quot;python3&quot;, &quot;index.py&quot;]
  </code></pre>
  <p>Take a look at this: <a href="https://www.geeksforgeeks.org/how-to-combine-multiple-base-images-using-single-dockerfile/" rel="nofollow noreferrer">https://www.geeksforgeeks.org/how-to-combine-multiple-base-images-using-single-dockerfile/</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2022-03-11T16:50:43.367Z
Answers: 2022-03-11T16:50:43.367Z
Answers: xjohnyx
Answers: <p>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:</p>
  <p><code>docker run nvcr.io/nvidia/pytorch:18.04-py3</code></p>
  <p>or</p>
  <p><code>docker run c3555fec4fe6</code></p>
  <p>or even</p>
  <p><code>docker run c3</code></p>
  <p>you can give your docker images a more reasonable name with</p>
  <p><code>docker image tag nvcr.io/nvidia/pytorch:18.04-py3 pytorch</code></p>
  <p>and run that with</p>
  <p><code>docker run pytorch</code></p>
  <hr />
  <p>see</p>
  <ul>
  <li><p><code>man docker-run</code></p>
  </li>
  <li><p><code>man docker-image-tag</code></p>
  </li>
  </ul>
  <p>and <a href="https://docs.docker.com/engine/reference/commandline/run/" rel="nofollow noreferrer">https://docs.docker.com/engine/reference/commandline/run/</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2022-03-11T14:53:05.770Z
Answers: 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.`
Answers: Levent Ozbek
Answers: CC BY-SA 4.0
Answers: 2022-03-11T15:21:33.800Z
Answers: 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`
Answers: Peter Turner
Answers: CC BY-SA 4.0
Answers: 2022-03-11T15:54:34.470Z
Answers: I'm running Ubuntu 21.10
Answers: Levent Ozbek
Answers: CC BY-SA 4.0
Answers: 2022-03-11T15:59:58.220Z
Answers: 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.
Answers: Peter Turner
Answers: CC BY-SA 4.0
Answers: 2022-03-11T16:27:53.447Z
Answers: I already have `/var/lib/docker/containers`. I think docker is just not turning this image into a container..
Answers: Levent Ozbek
Answers: CC BY-SA 4.0
Answers: 2022-03-11T16:41:46.327Z
Answers: @oo92 check syslog or `journalctl -f` while you run `docker run`
Answers: Peter Turner
Answers: CC BY-SA 4.0
Answers: 2022-03-11T14:37:47.933Z
Answers: 2022-03-11T14:37:47.933Z
Answers: Peter Turner
Body: <p>I have this following image:</p>
  <pre><code>REPOSITORY               TAG         IMAGE ID       CREATED       SIZE
  nvcr.io/nvidia/pytorch   18.04-py3   c3555fec4fe6   3 years ago   5.9GB
  </code></pre>
  <p>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.</p>
  
Tags: <docker><containers><ubuntu>
Title: How to create a container from an image
UserDisplayName: Levent Ozbek
ThreadText: # How to create a container from an image
  
  (Asked by: username_0 on 2022-03-11)
  
  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.
  
  **Tags:** docker, containers, ubuntu
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2022-03-11. Score: 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/>
  
  
  ---
  
  ### Answer by username_2 on 2022-03-11. Score: 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/>
  
  > **Comments:**
  > **username_0**: 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.`  
  > **username_2**: 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`  
  > **username_0**: I'm running Ubuntu 21.10  
  > **username_2**: 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.  
  > **username_0**: I already have `/var/lib/docker/containers`. I think docker is just not turning this image into a container..  
  > **username_2**: @oo92 check syslog or `journalctl -f` while you run `docker run`  
  
  ---
  
  