1

Goal:

I'm trying to copy a file from my computer into the following repository:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
crisbal/torch-rnn   base                90e6f8c8be88        7 months ago        1.173 GB

Information:

I inspect the IMAGE ID in order to find the Container value.

$ docker inspect 90e6f8c8be88 OUTPUT:

[
    {
        "Id": "sha256:90e6f8c8be88e51e1bbca2bd6e5288d49ef07cd7bb39fea92b1e5ff22359635f",
        "RepoTags": [
            "crisbal/torch-rnn:base"
        ],
        "RepoDigests": [
            "crisbal/torch-rnn@sha256:b379131dc0356a2d0be3b16c8aadccafea8d18a2a81dda5af53136c9ac0cf9
7e"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2016-05-15T12:11:40.123276779Z",
        "Container": "dbd5803b8c916411205323a11c005e15347b4b9496f1e32f571dbe65c43b8719",
        "ContainerConfig": {
            "Hostname": "3713552cb044",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/root/torch/install/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbi
n:/bin",
                "DEBIAN_FRONTEND=noninteractive",
                "DEBCONF_NONINTERACTIVE_SEEN=true",
                "LUA_PATH=/root/.luarocks/share/lua/5.1/?.lua;/root/.luarocks/share/lua/5.1/?/init.l
ua;/root/torch/install/share/lua/5.1/?.lua;/root/torch/install/share/lua/5.1/?/init.lua;./?.lua;/roo
t/torch/install/share/luajit-2.1.0-beta1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5
.1/?/init.lua",
                "LUA_CPATH=/root/torch/install/lib/?.so;/root/.luarocks/lib/lua/5.1/?.so;/root/torch
/install/lib/lua/5.1/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so",
                "LD_LIBRARY_PATH=/root/torch/install/lib:",
                "DYLD_LIBRARY_PATH=/root/torch/install/lib:"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) WORKDIR /root/torch-rnn"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:4742fe1066703d83130ca9a669b44a431702ffc8b776601aebe126e7db50c906",
            "Volumes": null,
            "WorkingDir": "/root/torch-rnn",
            "Entrypoint": null,
            "OnBuild": [],
            "Labels": {}
        },
        "DockerVersion": "1.10.2",
        "Author": "Cristian Baldi \"bld.cris.96@gmail.com\"",
        "Config": {
            "Hostname": "3713552cb044",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/root/torch/install/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbi
n:/bin",
                "DEBIAN_FRONTEND=noninteractive",
                "DEBCONF_NONINTERACTIVE_SEEN=true",
                "LUA_PATH=/root/.luarocks/share/lua/5.1/?.lua;/root/.luarocks/share/lua/5.1/?/init.l
ua;/root/torch/install/share/lua/5.1/?.lua;/root/torch/install/share/lua/5.1/?/init.lua;./?.lua;/roo
t/torch/install/share/luajit-2.1.0-beta1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5
.1/?/init.lua",
                "LUA_CPATH=/root/torch/install/lib/?.so;/root/.luarocks/lib/lua/5.1/?.so;/root/torch
/install/lib/lua/5.1/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so",
                "LD_LIBRARY_PATH=/root/torch/install/lib:",
                "DYLD_LIBRARY_PATH=/root/torch/install/lib:"
            ],
            "Cmd": [
                "/bin/bash"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:4742fe1066703d83130ca9a669b44a431702ffc8b776601aebe126e7db50c906",
            "Volumes": null,
            "WorkingDir": "/root/torch-rnn",
            "Entrypoint": null,
            "OnBuild": [],
            "Labels": {}
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 1172734794,
        "VirtualSize": 1172734794,
        "GraphDriver": {
            "Name": "aufs",
            "Data": null
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:7394707b3914f5b790ab676160cf44bc8987afaf6cff498644e65dd464e5a7bf",
                "sha256:1822b2b471224231a3897509de16ee85cfa62e2141fd56adf3d90b83d11af4fd",
                "sha256:4e2fee1e7083e29fd2b6186410a40f334acfdcf0ad49343cfb19c728a971fd6d",
                "sha256:5b5be35aaec46eb9b8099c062436783f071b8d87bf039c4fc0b0748939ca71c8",
                "sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
                "sha256:92d83bbbef9e6179f1d00c97a350c852472320340e89c84783f57839c7e674c9",
                "sha256:7efcc7a852afab84b20600433282efc6e5533cc8cc9fbfe169d6abfc98f3ad21",
                "sha256:579a21b228a5ed1f0ccd6f5627bbf377bf1b76826c6fb851ee1b247af7f30a82",
                "sha256:c1c66cc65895c9690f23cb4d14900a01af34b7ebff03950024211903ba500cbd",
                "sha256:d2a8da673882bb1a3a09d84ef5e5d322093413e469ecb10006b3c03839038361",
                "sha256:18d247d325a043c55b45df34e6585db08369662587eb327b2c3d34f5cc180c18",
                "sha256:df6148262d5b23a1d25487eff9edde40c36c18c7391802277456f69a8266693a",
                "sha256:afa2abf30b9efaab98ed72656f71799fcce353996ccd5be24c18be0016888690",
                "sha256:d75eea40967819b212498fc7e9d78dfc3e5483b04b0cd8b01d7c683b6c12a50e",
                "sha256:139fe6eee4b6d4bf9bd4cf1f4bf08caa3bafb70662e1ac1c670c7636309e1a07"
            ]
        }
    }
]

Using the Container value taken from the inspection:

docker cp comments.txt dbd5803b8c916411205323a11c005e15347b4b9496f1e32f571dbe65c43b8719:/comments.txt

OUTPUT:

Error response from daemon: No such container: dbd5803b8c916411205323a11c005e15347b4b9496f1e32f571dbe65c43b8719

How can I add a file from my computer to a Docker container?

Craig
  • 11
  • 2
  • Try to use 90e6 as id in your `docker cp` as this is what you use in your `docker inspect` – user2915097 Dec 31 '16 at 20:27
  • @user2915097 That will produce the same result. – Owen Dec 31 '16 at 20:49
  • you say `I inspect the IMAGE ID in order to find the Container value.` that is wrong, as you can do `docker run --name container1 image` and then `docker run --name container2 image` and so, now check with `docker ps` you should have your 2 containers running – user2915097 Dec 31 '16 at 21:10
  • Possible duplicate of [Copying files from host to docker container](http://stackoverflow.com/questions/22907231/copying-files-from-host-to-docker-container) – Marcin Kłopotek Jan 01 '17 at 15:14

1 Answers1

2

What you see and inspect is an image: crisbal/torch-rnn

You would need to run a container form that image in order to use docker cp.

The docker cp utility copies the contents of SRC_PATH to the DEST_PATH.
You can copy from the container’s file system to the local machine or the reverse, from the local filesystem to the container

You don't copy into a repository or an image within that repo, but to a running (or stopped) container created from that image.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250