Home  >  Article  >  Operation and Maintenance  >  How to copy files to docker container under linux

How to copy files to docker container under linux

王林
王林Original
2020-03-25 16:56:518969browse

How to copy files to docker container under linux

1. View all docker containers

docker ps
// 775c7c9ee1e1为docker中的id
docker exec -it 775c7c9ee1e1 /bin/bash

(Recommended learning video: linux video tutorial)

2. From Linux system copies files to the container

Get the long ID of the container

// python为docker容器内运行的项目名
docker inspect -f '{{.ID}}' python

Then copy. Note: Be sure to exit the container when executing the docker command, otherwise an error will be reported

From the container It's the same when copied out. Just change the position behind docker cp. You don't need a long path when copying. You can use the container name displayed by docker ps.

// docker cp 本地路径 容器长ID:容器路径
docker cp /usr/local/test.txt 38ef22f922704b32cf2650407e16b146bf61c221e6b8ef679989486d6ad9e856:/usr/local/tomcat/webapps test.txt

Recommended related tutorials: linux tutorial

The above is the detailed content of How to copy files to docker container under linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn