How to view files in Docker image

How to view files in Docker image

How to view files in a docker image

1. If it is already running

For the already running image, we can view it by its ContrainerID

docker attach ContainerID

In this way, the corresponding container must be running and not in the stopped state.

2. If it is not running

If it is not running, you can copy the files in the Docker image to the host. The command is as follows:

docker cp <container name>:<path> <host path>

like:

sudo docker cp nginx-ubuntu-container:/etc/apt/sources.list ~/Documents/

This method does not require the corresponding container to be running.

Content extension:

Copy the file from the container to the host, which is the id of the container process

docker cp container process id:/logs/temp ./

Get data from the host via scp

scp remote_user@remoteIp:/logs.temp ./

This is the end of this article about how to view files in docker images. For more information about how to view file contents in docker images, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Docker gets the image and reports an error: docker: Error response from daemon
  • How to pull the docker image to view the version
  • Summary of Docker's commonly used commands for clearing container images
  • How to delete an image in Docker
  • 12 tips to optimize Docker image security

<<:  Detailed explanation of JavaScript clipboard usage

>>:  Tutorial on installing the unpacked version of mysql5.7 on CentOS 7

Recommend

Pessimistic locking and optimistic locking in MySQL

In relational databases, pessimistic locking and ...

Solve the problem that Docker must use sudo operations

The steps are as follows 1. Create a docker group...

Three ways to avoid duplicate insertion of data in MySql

Preface In the case of primary key conflict or un...

JS realizes picture digital clock

This article example shares the specific code of ...

How to test network speed with JavaScript

Table of contents Preface Summary of the principl...

Using vsftp to build an FTP server under Linux (with parameter description)

introduce This chapter mainly introduces the proc...

How to import CSS styles into HTML external style sheets

The link-in style is to put all the styles in one...

Nginx one domain name to access multiple projects method example

Background Recently, I encountered such a problem...

Comprehensive understanding of html.css overflow

Comprehensive understanding of html.css overflow ...

Implementation of mysql backup strategy (full backup + incremental backup)

Table of contents Design scenario Technical Point...

Summary of CSS sibling element floating analysis

float:left/right/none; 1. Same level floating (1)...

Use of Linux sed command

1. Function Introduction sed (Stream EDitor) is a...