How to copy files to docker container under linux

王林
Release: 2020-03-25 16:56:51
Original
8961 people have browsed it

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
Copy after login

(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
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template