본문 바로가기

머신러닝,딥러닝

how to use docker image and container in ML,DL?

today , I'm going to do a simple exercise with docker image and container.

If you are a non- major in Data Science and you are interested in deep learning or machine learning, I think you should know.

anyway, I'll start explaining right away. I'm not going to explain the principle about docker. 

 

 

The name of the image used by Docker basically consists of a repository name/image name: tag.

for example, 

 

tensorflow/tensorflow:2.1.1-gpu

 

'tensorflow' in the left side means repository name. Next to '/', you can see other 'tensorflow'. it means image name. The letter after the colon means the version. 

 

The storage name means the location where the image is stored.  An image without a repository name is the official image of Docker Hub, the image repository provided by Docker by default.  However, it is sometimes necessary to omit the repository name when creating the image, as it is not necessary.

 

The image name indicates what the image does. 

You can see that the above example is an image for creating a TensorFlow container.

The name of the image cannot be omitted and must be set.

 

Tags are used for image versioning or revision management.

Typically, you specify the version as in 2.1.1, but if you omit the tag, the Docker engine recognizes the tag in the image as latest.

 

 

I'll download the Docker image from above.

Download it using the pull command.

You can check the current Docker image on Linux through the docker images command.

 

 

 

 

 

 

Now let's create a container using the downloaded Docker image.

Then start the container and access the container from the terminal.

 

 

 

 

 

When creating a container, you can use the create command. At this time, a container is created and is in a running state.

You don't need to use create when you access the container again.

In this case, run the container using the start command and connect with the attach command.

 

Next, connect through vsc.

 

 

 

 

First, install remote-container from extension. 

And press the >< sign at the bottom left corner. 

You will see a button called attach to running container. Press that button.

 

 

 

 

At this point, you will see a list of running containers. If there are no running containers, nothing is visible.

After this, you will see a button called install in container. You can install it with this.

 

 

 

Now, last. Let's see if it works.

 

 

 

Now I created a container using docker and even connected vsc. Now let's do our machine learning project :)