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

Graphical explanation of the function call of proto file in Vue

1. Compile proto Create a new proto folder under ...

Enable sshd operation in docker

First, install openssh-server in docker. After th...

Mysql 5.7.17 winx64 installation tutorial on win7

Software version and platform: MySQL-5.7.17-winx6...

How to use JavaScript to get the most repeated characters in a string

Table of contents topic analyze Objects of use So...

Use of MySQL query rewrite plugin

Query Rewrite Plugin As of MySQL 5.7.6, MySQL Ser...

HTML marquee tag usage examples

This tag is not part of HTML3.2 and only supports ...

More Features of the JavaScript Console

Table of contents Overview console.log console.in...

About Vue virtual dom problem

Table of contents 1. What is virtual dom? 2. Why ...

WML tag summary

Structure related tags ---------------------------...

How to add java startup command to tomcat service

My first server program I'm currently learnin...

Detailed explanation of nginx anti-hotlink and anti-crawler configuration

Create a new configuration file (for example, go ...

Detailed steps to install web server using Apache httpd2.4.37 on centos8

Step 1: yum install httpd -y #Install httpd servi...

Example of utf8mb4 collation in MySQL

Common utf8mb4 sorting rules in MySQL are: utf8mb...