NOt able to copy file from docker server to container , although container is there

NOt able to copy file from docker server to container , although container is there

e68422e4a84fc7a329c65cc3835f6a2f138ed1682b2d8a0f0d29abfb595ac95e
shyam@DESKTOP-OO7EVK2:/$ docker cp port01.txt web001:/
lstat //port01.txt: no such file or directory
shyam@DESKTOP-OO7EVK2:/$ docker cp port01.txt web01:/
lstat //port01.txt: no such file or directory
shyam@DESKTOP-OO7EVK2:/$ docker ps -a
CONTAINER ID   IMAGE                       COMMAND                  CREATED              STATUS                      PORTS                  NAMES
e68422e4a84f   nginx                       "/docker-entrypoint.…"   54 seconds ago       Up 54 seconds               0.0.0.0:8081->80/tcp   web002
f872d2e868a9   nginx                       "/docker-entrypoint.…"   About a minute ago   Created                                            web001
4a4c9e4d46ad   nginx                       "/docker-entrypoint.…"   18 minutes ago       Up 18 minutes               0.0.0.0:8080->80/tcp   port01

Did you really create a file in the Linux root? Unless you did it as a root user, you don’t even have permission to do that. If the file is not there, as the error message cleary says, it is normal to have the error message.

Nothing at all indicated in the error message that the container is not there. It is the file which is not there.

I have not used sudo but with out sudo when I created file using touch command it did not give any error .
however I tried now with sudo, even I am trying to give right password it is not allowing me to proceed further. could you please advise on this ?

shyam@DESKTOP-OO7EVK2:/$ touch shyamfile.txt
touch: cannot touch 'shyamfile.txt': Permission denied
shyam@DESKTOP-OO7EVK2:/$ sudo touch shyamfile.txt
[sudo] password for shyam:
Sorry, try again.
[sudo] password for shyam:
Sorry, try again.
[sudo] password for shyam:
sudo: 3 incorrect password attempts

Please share following outputs:

docker info
ls -l

The ls -l command must be done in the folder where you want to use docker cp.

Note: if you use docker cp for anything else than “testing something out” or copying files from the container to the host, you most likely try to do something that either should be done by binding a host folder as volume, or by creating a new image where the file is copied into the image.

shyam@DESKTOP-OO7EVK2:~$ docker info
ls -l
Client:
Version: 24.0.7
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.16.2-desktop.1
Path: /usr/local/lib/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.29.2-desktop.2
Path: /usr/local/lib/docker/cli-plugins/docker-compose
debug: Get a shell into any image or container (Docker Inc.)
Version: 0.0.34
Path: /usr/local/lib/docker/cli-plugins/docker-debug
desktop: Docker Desktop commands (Alpha) (Docker Inc.)
Version: v0.0.15
Path: /usr/local/lib/docker/cli-plugins/docker-desktop
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.2
Path: /usr/local/lib/docker/cli-plugins/docker-dev
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.25
Path: /usr/local/lib/docker/cli-plugins/docker-extension
feedback: Provide feedback, right in your terminal! (Docker Inc.)
Version: v1.0.5
Path: /usr/local/lib/docker/cli-plugins/docker-feedback
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v1.3.0
Path: /usr/local/lib/docker/cli-plugins/docker-init
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: /usr/local/lib/docker/cli-plugins/docker-sbom
scout: Docker Scout (Docker Inc.)
Version: v1.13.0
Path: /usr/local/lib/docker/cli-plugins/docker-scout

Server:
Containers: 37
Running: 26
Paused: 0
Stopped: 11
Images: 55
Server Version: 27.2.0
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 nvidia runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 8fc6bcff51318944179630522a095cc9dbf9f353
runc version: v1.1.13-0-g58aa920
init version: de40ad0
Security Options:
seccomp
Profile: unconfined
Kernel Version: 5.15.153.1-microsoft-standard-WSL2
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.72GiB
Name: docker-desktop
ID: b587712e-7ae6-4ddf-a393-73384c4329a1
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Labels:
com.docker.desktop.address=unix:///var/run/docker-cli.sock
Experimental: true
Insecure Registries:
hubproxy.docker.internal:5555
127.0.0.0/8
Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
WARNING: daemon is not using the default seccomp profile
total 40
-rw-r–r-- 1 shyam shyam 269 Sep 21 15:00 Dockerfile
drwxr-xr-x 5 shyam shyam 4096 Feb 14 21:53 Dockerfiles
drwxr-xr-x 2 shyam shyam 4096 Sep 21 11:26 akstest
drwxr-xr-x 2 shyam shyam 4096 Sep 16 21:13 azp-agent-in-docker
drwxr-xr-x 5 shyam shyam 4096 Sep 21 20:59 dotnet-album-viewer
drwxr-xr-x 2 shyam shyam 4096 Sep 26 13:32 java
-rw-r–r-- 1 shyam shyam 28 Feb 8 15:41 port.txt
-rw-r–r-- 1 shyam shyam 28 Feb 8 15:41 port01.txt
drwxr-xr-x 2 shyam shyam 4096 Feb 17 12:10 test
drwxr-xr-x 6 shyam shyam 4096 Sep 16 19:22 webstore-appinsights-monitor


Please, format your post according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.

Example code block:

```
echo "I am a code."
echo "An athletic one, and I wanna run."
```

After fixing your post, please send a new comment so people are notified about the fixed content.