# Running and inspecting images

You can run any image in a container from within VS Code. VS Code also provides functionality for inspecting, managing and otherwise working with images and containers on your machine.

{% tabs %}
{% tab title="Exercise" %}

* Run the "i-love-lamp:latest" image from the Docker Explorer in VS Code
* View the application running on port 3000
* View the image logs
* Attach a shell to the running image and inspect the file system
* Stop the image
* Remove the image
  {% endtab %}

{% tab title="Answer" %}

* Open the Docker Explorer view by clicking on the Docker icon in the Activity Bar

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm6AZcBldO9D1ZxI2KQ%2F-Lm5n67h5J90i-IfAMfR%2Fimage.png?alt=media\&token=0e974d1b-ed12-4d49-990c-46f88e7e1dd9)

* In the "images" section, locate the "i-love-lamp" image. Expand it to find the "latest" image.

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm6AZcBldO9D1ZxI2KQ%2F-Lm5nJHqB-NEGqlaIRdK%2Fimage.png?alt=media\&token=b1996276-64ec-4ced-b312-e6609a931397)

* Right-click the image and select "Run"
* Notice that there is now a container running

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm6AZcBldO9D1ZxI2KQ%2F-Lm5n_OjTR1JNGt7ZhNM%2Fimage.png?alt=media\&token=1f0e5213-7713-4e08-98c8-cedf22af29ab)

* Open your browser and navigate to "<http://localhost:3000>"
* View the application running in the Docker container

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm6AZcBldO9D1ZxI2KQ%2F-Lm5pef2Lg5kARO2_TA6%2Fimage.png?alt=media\&token=ab94e649-103d-4bb2-9e2e-a68effc19648)

* Right click the container in the "Containers" section of the Docker Explorer view and select "View Logs"
* View the logs from the container

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm6AZcBldO9D1ZxI2KQ%2F-Lm5puLfPyzITdY5Im01%2Fimage.png?alt=media\&token=8d3df7f3-910a-4440-95b9-33b3a49324f9)

* Right click the container in the "Containers" section of the Docker Explorer view and select "Attach Shell"
* The integrated terminal will open connected to the Docker container
* Navigate the file system with `cd` to change directory and `ls` to list the file system contents

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm6AZcBldO9D1ZxI2KQ%2F-Lm5qEfXzrEwomfnKtkv%2Fimage.png?alt=media\&token=7dc2c130-bc10-46ca-8fbe-869e4da4d7e3)

{% hint style="info" %}
Note that if you navigate to "/" with `cd /`, you will get to the root of the container. Notice how it appears as if the container is an entire Linux machine with a complete file system.
{% endhint %}

* Right click the container in the "Containers" section of the Docker Explorer view and select "Stop"
* Right click the container in the "Containers" section of the Docker Explorer view and select "Remove"
* The container will be removed from the "Containers" section in VS Code
  {% endtab %}
  {% endtabs %}
