Reputation: 574
I have created an application that uses docker. I have built an image like so: docker build -t myapp .
While in my image (using docker run -it myapp /bin/bash
to access), a image file is created.
I would like to obtain that file to view on my local as I have found out that viewing images on Docker is a complex procedure.
I tried the following: docker cp myapp:/result.png ./
based on suggestions seen on the webs, but I get the following error: Error response from daemon: No such container: myapp
Upvotes: 0
Views: 686
Reputation: 56657
myapp
is the name of the image, which is not a running container.
When you use docker run
, you are creating a container which is based on the myapp
image. It will be assigned an ID, which you can see with docker ps
. Example:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
aa58c8ff2f34 portainer/portainer "/portainer" 4 months ago Up 5 days 0.0.0.0:9909->9000/tcp portainer_portainer_1
Here you can see a container based on the portainer/portainer
image. It has the ID aa58c8ff2f34
.
Once you have the ID of your container, you can pass it to docker cp
to copy your file.
Another approach, which may be preferable if you are automating / scripting something, is to specify the name of the container instead of having to look it up.
docker run -it --name mycontainer myapp /bin/bash
This will create a container named mycontainer
. You can then supply that name to docker cp
or other commands. Note that your container still has an ID like in the above example, but you can also use this name to refer to it.
Upvotes: 1
Reputation: 71936
You could map a local folder to a volume in the image, and then copy the file out of the image that way.
docker run -it -v /place/to/save/file:/store myapp /bin/bash cp /result.png /store/
Upvotes: 1