docker拷貝文件

從容器往host拷貝

docker cp <containerId>:/file/path/within/container /host/path/target

從host拷貝到容器

docker cp foo.txt mycontainer:/foo.txt

或者git

docker exec -it <container_id> bash -c 'cat > /path/to/container/file' < /path/to/host/file/

或者github

docker ps

docker inspect -f   '{{.Id}}'  SHORT_CONTAINER_ID-or-CONTAINER_NAME

sudo cp path-file-host /var/lib/docker/aufs/mnt/FULL_CONTAINER_ID/PATH-NEW-FILE

kubectl

kubectl get pods --namespace=demo | grep myapp
kubectl exec -i myapp-kp1by --namespace=demo -- /bin/bash -c 'cat /gc.log.0.current' > myapp.gc

doc

相關文章
相關標籤/搜索