docker cp <Container ID or container name>:Path of the file you want to copy Copy destination path
Can be copied with. Click here for the reference.
I'm running oracle with docker and want to check the connection information, so copy tnsnames.ora.
When container ID is specified
#Check container ID(CONTAINER ID)
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d3e6c3fd1a85 oracle/database:19.3.0-ee "/bin/sh -c 'exec $O…" 2 hours ago Up 2 hours (healthy) 0.0.0.0:1521->1521/tcp, 0.0.0.0:5500->5500/tcp orcl
#make a copy
$ docker cp d3e6c3fd1a85:/opt/oracle/oradata/dbconfig/ORCLCDB/tnsnames.ora ./
#Check if you could copy
$ find tnsnames.ora
tnsnames.ora
When specifying the container name
#Look up the container name(NAMES)
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d3e6c3fd1a85 oracle/database:19.3.0-ee "/bin/sh -c 'exec $O…" 2 hours ago Up 2 hours (healthy) 0.0.0.0:1521->1521/tcp, 0.0.0.0:5500->5500/tcp orcl
#make a copy
$ docker cp orcl:/opt/oracle/oradata/dbconfig/ORCLCDB/tnsnames.ora ./
#Check if you could copy
$ find tnsnames.ora
tnsnames.ora
$ docker version
Client: Docker Engine - Community
Cloud integration 0.1.18
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 16:58:31 2020
OS/Arch: darwin/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:07:04 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.3.7
GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.7
BuildVersion: 19H2
-Copy files between host and container with Docker -Copy files from Docker container to host -Install Oracle 19c on Mac with Docker and build a development environment
Recommended Posts