![关注抖音创业](https://img.kancloud.cn/c5/ce/c5ced2ea291122851697114ca415ff95_1125x1680.png) [TOC] # docker cp > docker cp 用于宿主机和docker容器之间传递数据 ## 语法 ``` docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|- docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH ``` ## 查看容器 ``` docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 889b590449aa kong:0.14.1 "/docker-entrypoint.…" 3 days ago Up 3 days 0.0.0.0:8000-8002->8000-8002/tcp, 0.0.0.0:8443-8444->8443-8444/tcp kong ``` ## 将宿主机中文件拷贝到kong容器已存在目录 ``` docker cp /root/pm/web/resources.lua 889b590449aa:/usr/local/share/lua/5.1/kong/zxapi/web/ ``` ## 从kong容器拷贝文件到宿主机 ``` docker cp 889b590449aa:/usr/local/share/lua/5.1/kong/zxapi/web /root/pm/web/tmp/ ``` ## 将宿主机中文件拷贝到kong容器并重命名 ``` docker cp /root/pm/web 889b590449aa:/usr/local/share/lua/5.1/kong/zxapi/webrename ``` # 容器停止 `docker stop 容器ID或容器名 ; 比较优雅` `docker kill 容器ID或容器名; ` # 容器重启 `docker restart 容器ID或容器名`