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.

community@betterstack.com

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
You’re Temporarily Blocked
Files & Folders You Can Safely Delete in Windows 11
Skigebiet Portillo - Skiurlaub - Skifahren - Testberichte
Craigslist Home Health Care Jobs
Dairy Queen Lobby Hours
Kevin Cox Picks
Caesars Rewards Loyalty Program Review [Previously Total Rewards]
Beacon Schnider
Overnight Cleaner Jobs
Is Sportsurge Safe and Legal in 2024? Any Alternatives?
Here's how eating according to your blood type could help you keep healthy
W303 Tarkov
Johnston v. State, 2023 MT 20
Sams Early Hours
Bjork & Zhulkie Funeral Home Obituaries
Hijab Hookup Trendy
7440 Dean Martin Dr Suite 204 Directions
Craigslist Farm And Garden Tallahassee Florida
Snow Rider 3D Unblocked Wtf
"Une héroïne" : les funérailles de Rebecca Cheptegei, athlète olympique immolée par son compagnon | TF1 INFO
Mflwer
Der Megatrend Urbanisierung
Zalog Forum
V-Pay: Sicherheit, Kosten und Alternativen - BankingGeek
BMW K1600GT (2017-on) Review | Speed, Specs & Prices
Kcwi Tv Schedule
Lost Pizza Nutrition
Regal Amc Near Me
Devotion Showtimes Near Regency Buenaventura 6
European Wax Center Toms River Reviews
Roseann Marie Messina · 15800 Detroit Ave, Suite D, Lakewood, OH 44107-3748 · Lay Midwife
Purdue Timeforge
Swimgs Yuzzle Wuzzle Yups Wits Sadie Plant Tune 3 Tabs Winnie The Pooh Halloween Bob The Builder Christmas Autumns Cow Dog Pig Tim Cook’s Birthday Buff Work It Out Wombats Pineview Playtime Chronicles Day Of The Dead The Alpha Baa Baa Twinkle
Www.craigslist.com Syracuse Ny
Metra Union Pacific West Schedule
Murphy Funeral Home & Florist Inc. Obituaries
Steven Batash Md Pc Photos
Moxfield Deck Builder
Cherry Spa Madison
Babbychula
Walgreens Agrees to Pay $106.8M to Resolve Allegations It Billed the Government for Prescriptions Never Dispensed
Barber Gym Quantico Hours
Worcester County Circuit Court
Lamp Repair Kansas City Mo
Holzer Athena Portal
Europa Universalis 4: Army Composition Guide
Paperlessemployee/Dollartree
Who uses the Fandom Wiki anymore?
What Time Do Papa John's Pizza Close
Estes4Me Payroll
Fishing Hook Memorial Tattoo
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.