How to view the contents of docker images? | Better Stack Community (2024)

Better Stack Team

Updated on November 23, 2023

To view the contents of a Docker image, you can use the docker run command to start a container from the image and then use commands such as ls or cat to view the contents of the container. If you prefer not to start the container, there is an option for docker image save command.

View contents while the container is running

  1. Open your terminal and run the following command to start a container from the Docker image:

    Copied!

    docker run --name <container_name> <image_name>

    Replace <container_name> with a name for your container, and <image_name> with the name of the Docker image you want to view the contents of.

  2. Once the container is running, you can use commands such as ls or cat to view the contents of the container. For example, to list the contents of the root directory, you can run:

    Copied!

    docker exec <container_name> ls /

    This command will show you the files and directories in the root directory of the container.

    You can also view the contents of a specific file by running the cat command followed by the path to the file. For example:

    Copied!

    docker exec <container_name> cat /path/to/file
  3. Once you are done, you can stop and remove the container using the following command:

    This will stop and remove the container from your system.

View contents without starting the container

Use the following command to directly save the contents of the image to a tar file:

Copied!

docker image save my-image:latest > my-image.tar

You can also export the container's filesystem. If you don’t need to save or open the archive, instead preferring to get the file list in your terminal, modify thetarcommand:

Copied!

docker export my-container | tar t > my-container-files.txt

Third option is to view the docker image history:

Copied!

docker image history my-image:latest

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guestwriting program and get paid for writing amazing technical guides. We'll get them to the rightreaders that will appreciate them.

Write for us

Writer of the month

How to view the contents of docker images? | Better Stack Community (10)

Marin Bezhanov

Marin is a software engineer and architect with a broad range of experience working...

Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world.Make a public repository and share it with us at our email.

[email protected]

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github

How to view the contents of docker images? | Better Stack Community (2024)
Top Articles
How To Communicate With Your Stubborn Husband (Or Wife)
On-Ramp | The best solution for buying crypto on your site
Lorton Transfer Station
Angela Babicz Leak
Tabc On The Fly Final Exam Answers
Unblocked Games Premium Worlds Hardest Game
What Are the Best Cal State Schools? | BestColleges
St Petersburg Craigslist Pets
Horoscopes and Astrology by Yasmin Boland - Yahoo Lifestyle
Craigslist Kennewick Pasco Richland
DL1678 (DAL1678) Delta Historial y rastreo de vuelos - FlightAware
How To Get Free Credits On Smartjailmail
Gunshots, panic and then fury - BBC correspondent's account of Trump shooting
Cinepacks.store
Jasmine
Bill Devane Obituary
Ohiohealth Esource Employee Login
Methodist Laborworkx
Dump Trucks in Netherlands for sale - used and new - TrucksNL
Dexter Gomovies
Studentvue Columbia Heights
Used Sawmill For Sale - Craigslist Near Tennessee
360 Tabc Answers
U Break It Near Me
Ubg98.Github.io Unblocked
Accident On The 210 Freeway Today
Kirksey's Mortuary - Birmingham - Alabama - Funeral Homes | Tribute Archive
Rufus Benton "Bent" Moulds Jr. Obituary 2024 - Webb & Stephens Funeral Homes
Reicks View Farms Grain Bids
2011 Hyundai Sonata 2 4 Serpentine Belt Diagram
10-Day Weather Forecast for Santa Cruz, CA - The Weather Channel | weather.com
Bfri Forum
+18886727547
The value of R in SI units is _____?
Melissa N. Comics
Σινεμά - Τι Ταινίες Παίζουν οι Κινηματογράφοι Σήμερα - Πρόγραμμα 2024 | iathens.gr
Joplin Pets Craigslist
Ark Unlock All Skins Command
Skip The Games Ventura
Afspraak inzien
Pitchfork's Top 200 of the 2010s: 50-1 (clips)
Dee Dee Blanchard Crime Scene Photos
Jasgotgass2
Www Usps Com Passport Scheduler
Chathuram Movie Download
If You're Getting Your Nails Done, You Absolutely Need to Tip—Here's How Much
Rocky Bfb Asset
Exploring the Digital Marketplace: A Guide to Craigslist Miami
Studentvue Calexico
Victoria Vesce Playboy
Cvs Coit And Alpha
Canonnier Beachcomber Golf Resort & Spa (Pointe aux Canonniers): Alle Infos zum Hotel
Latest Posts
Article information

Author: Margart Wisoky

Last Updated:

Views: 6835

Rating: 4.8 / 5 (58 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Margart Wisoky

Birthday: 1993-05-13

Address: 2113 Abernathy Knoll, New Tamerafurt, CT 66893-2169

Phone: +25815234346805

Job: Central Developer

Hobby: Machining, Pottery, Rafting, Cosplaying, Jogging, Taekwondo, Scouting

Introduction: My name is Margart Wisoky, I am a gorgeous, shiny, successful, beautiful, adventurous, excited, pleasant person who loves writing and wants to share my knowledge and understanding with you.