Cierniostwor
Cierniostwor

Reputation: 449

Docker: Reading files from inside the container without entering it

I am currently using the

sudo docker exec -it <container_name> /bin/bash

command to enter the container and then

cat <my_file_path>

to display the contents of the file. What one command should I use to display the contents of a file in a container without enter on it? Edit:

sudo docker exec <container_name> cat <my_file_path>

work correct, but remember to use absolute path, because ~/ not work

Upvotes: 0

Views: 2301

Answers (2)

rjangheldotcom
rjangheldotcom

Reputation: 1

I tried to access the same pod using Lens, and it gave me below command line to access the POD:

kubectl exec -i -t -n NAME_SPACE POD_NAME -c TAG -- sh -c "clear; (bash || ash || sh)"

Upvotes: -2

Hans Kilian
Hans Kilian

Reputation: 25544

You can do

sudo docker exec <container_name> cat <my_file_path>

Upvotes: 2

Related Questions