1. Building an image by pulling
Command:
docker image pull <image_name>
For example, I recently used:
docker image pull nvcr.io/nvidia/pytorch:23.05-py3
2. Building an image using Dockerfile
Create “Dockerfile” in your directory, and include the followings in the file:
FROM <existing_image_name>
RUN <commands you want to execute in terminal when the image is built>
There are other commands you can contain.
3. Creating a container based on an existing image
docker run --gpus all -it --name <container_name> <image_name>
For example,
docker image pull test_container pytorch/pytorch:latest
+ If you want to access to a container via VScode:
- Right-click on the container
- Select “Attach Visual Studio Code”