Docker "Can't add file <path> to tar: readlink <path> The system cannot find the file specified" - windows

I'm a beginner at docker trying to get it working on my Windows 10 machine using creator's update bash subsystem. My dockerfile builds fine on my mac, but when I try docker build from the same file on windows, I get errors like the following:
time="2017-08-28T14:44:36-07:00" level=error
msg="Can't add file \\\\?\\C:\\Users\\username\\Workspace\\...\\node_modules\\.bin\\nodemon
to tar: readlink \\\\?\\C:\\Users\\username\\Workspace\\...\\node_modules\\.bin\\nodemon:
The system cannot find the file specified."
This is printed out for all of my node_modules dependencies. My first question is: What is triggering this "add" operation for all of my node_modules? These error messages are printed out before the first line of my dockerfile is executed
Step 1/25 : FROM ubuntu:14.04
Second, does this issue have something to do with different paths in windows? To me, the weirdest part about the errors is the strange path \\\\?\\C:\\Users\\username. What is going on here with the excessive slashes and a question mark in the path?
Third, is it just me? Or does everyone encounter problems when using docker on windows bash subsystem?
NOTE: I've tried setting up the Docker Toolbox and running the quickstart terminal. I get the following error from running the quickstart terminal
Error with pre-create check:
"This computer is running Hyper-V. VirtualBox won't boot a 64bits VM when Hyper-V is activated. Either use Hyper-V as a driver, or disable the Hyper-V hypervisor. (To skip this check, use --virtualbox-no-vtx-check)"
Looks like something went wrong in step ´Checking if machine default exists
´... Press any key to continue...
So I've tried making sure hyper-v is enabled from this article here
NOTE 2: I've also made sure that my C drive is shared with my containers

Related

linux subsystem on windows, how to set working directory to a folder on windows?

I am trying to import a file on windows 11 to a linux subsystem (Ubuntu 22.04.1) while it is connected to docker. I am new to this so I am sorry if I am making obvious mistakes. To my understanding (I am following this tutorial: https://degauss.org/using_degauss.html), I need docker running first and then open my linux subsystem. However once I get to cd then it gives me the following error: -bash: cd: too many arguments. What I need to do is set the working directory to a specific folder so I can proceed with the next step.
typing pwd simply showed me that I am in home\(username I created when installing the linux subsystem)
I am new to linux and docker so an easy to understand answer is greatly appreciated.
Thanks.
I have tried cd and then name of path for example E:\Users\Name\Desktop\folder one\folder two\folder where file is and I got -bash: cd: too many arguments. I also changed \ to / and got the same error. I thought it would set the working directory (folder where file is).
Docker is connected to linux subsystem as I did the hello-world test successfully
Linux does not know about drives, there are only directories. Generally, a WSL mounts windows drives, which means you can find them under /mnt: generally you should have /mnt/c for your C:\-drive, please check if you can access /mnt/e for accessing your E:\-drive.
Your directory should be accessible from:
cd /mnt/c/Users/Name/Desktop/"folder one"/"folder two"
Good luck

docker env: bash\r: No such file or directory

While locally deploying an app in PyCharm on windows10, I have encountered several mistakes.
Make test command returned following mistake:
service "core" is not running container #1
make: *** [Makefile:60: test] Error 1
And indeed container status with the command make ps returned exited(127). When I have checked docker logs for the container in question, I've seen:
/usr/bin/env: ‘bash\r’: No such file or directory
In this thread, this mistake is connected to how windows processes line endings of files from different OS. The usual solution is:
git config --global core.autocrlf false
But after running the code and updating current git repo and restarting the containers, i still get the same mistake. What might be the issue here?
What did helped me
I assume that the problem was in the windows line endings in the Unix-based containers.
To solve it I found two very helpful instructions:
Configure your line separators in the PyCharm https://www.jetbrains.com/help/pycharm/configuring-line-endings-and-line-separators.html
To clarify that changes were really enabled, I have checked the files in the notepad++
https://notepad-plus-plus.org/downloads/v8.1.9.3/
Also it was helpful to check the original code because part of the problem was the incorrect spelling of some commands.
When I use Windows in Docker and run a bash script, I have a similar problem, which I solve by using LF instead of CRLDF as the line separator.
in vscode, we can change it here

Docker for Desktop error during connect: Post A connection attempt failed because the connected party did not properly

I have freshly installed Docker for Desktop Edge in Windows 10 Home and try to build an image using the docker build command. But unfortunately, it didn't work for me, and got the below error :
CMD - docker build -t heet1996/post:0.0.1 .
error during connect: Post https://192.168.99.100:2376/v1.40/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&session=na8ugnpn6d8gnxl3z8ppx4gap&shmsize=0&t=heet1996%2Fpost%3A0.0.1&target=&ulimits=null&version=1: dial tcp 192.168.99.100:2376: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Earlier I was using a docker toolbox so I had to remove all the environment variables related to the Docker in my User variables before installing Docker for Desktop. After a lot of search on GitHub issues, I am still not getting the solution.
This is what I found in my service.txt file (C:\ProgramData\DockerDesktop\service.txt)
[18:27:22.232][LoggingMessageHandler][Info ] [f9b6b957] <Server end> POST http://localhost/dns/refresh-hosts -> 204 NoContent (took 118ms)
I got this error when i un-installed the docker toolbox and installed the docker desktop.
System Configuration:
OS: Windows 10 Home
Version: 21H1
Steps I Followed:
Un-installed the docker desktop.
Removed the all dockers related environment variables from the user variables.
Navigation: This System-> Properties-> Advance System Settings-> Environment Variables-> User Variables.
Re-installed the docker desktop and it's started working properly.
Try to run it on Docker CLI instead of CMD
Open Powershell as Administrator and run the below commands
cd "C:\Program Files\Docker\Docker"
./DockerCli.exe -SwitchDaemon
Docker for windows must have:
[✓] Updated Windows 10 version >=2004
[✓] WSL 2 and Default Distro (i.e ubuntu)
The steps are well documented here. These are what to do after the installation:
To confirm ubuntu's installation, open C:/Windows/System32/bash.exe aka bash.
To test if docker is properly installed, run docker version on bash. This should print the docker client and server engine.
After successfully tested and confirmed the installations, try entering your command
$ docker build -t heet1996/post:0.0.1 .
here we are talking about using Docker with PowerShell and not with WSL. And also following the addition of variables in the environment variables of Windows.
Configuration when this response was made:
Windows 10 Pro 20H2 (Build 19042.867)
Docker 20.10.5
Powershell 5.1.19041.610
I also had to configure docker in a dirty way too much, after several hours of research and a comparison of installation on a clean Windows 10 I understood where my error was.
In addition to the user environment variable also make sure that you do not have DOCKER variables in the Windows system environment variables either.
Here is where my error was, I think it was due to the installation of the Docker module
I had the DOCKER_HOST variable in my system variable environment, so i deleted it.
If you want to check all your environment variables with Powershell:
[System.Environment]::GetEnvironmentVariables()
If you really want a Docker fresh installation on Windows, you need to delete the following folders:
C:\ProgramData\Docker
C:\Program Files\Docker\Docker
$HOME\AppData\Local\Docker
$HOME\AppData\Roaming\Docker
$HOME\AppData\Roaming\Docker Desktop
$HOME\.docker
my error, therefore, produced this error:
ERROR ==> error during connect: Get http://docker.artofshell:2376/v1.24/version: dial tcp: lookup docker.artofshell: no such host
After a complete uninstall of all docker (Via chocolatey, official docker ...) and by properly installing Docker from the official executable here everything is back to normal
Then if you want to use docker via Powershell you have to change the configuration of DockerCLI as you can see on many answers
Conclusion
It is possible to use docker with Powershell you must check if the
server daemon is used by Windows/amd64, you can modify the daemon with this command cd "C:\Program Files\Docker\Docker"; .\DockerCli.exe -SwitchDeamon
You can check the configuration of the daemon with the following command: docker version
You must remove all traces of old Docker installations if you had any
You must delete the environment variables from the old installation or from the docker toolbox
You must also activate the experimental features: information here

Docker: Mount volume from Windows host

I use 1.12 version of Docker on Windows, since I can't use the Hyper-V feature with the newer "native" version - so I have my quickstart terminal and communicate to docker host via the invisible underlying virtual box.
Now I have the problem, that I need to mount a local folder to a container, which worked successfully from within the docker-machine by adding
--volume="`pwd`:/root/data"
to the docker run command, but it does not when I launch the same command from my Windows quickstart terminal (even though pwd command works correctly in the terminal).
I tried to find the Windows specific settings for the directory and tested several combinations of format, but no luck. Can anyone help me out on how to correctly specify a Windows folder (e.g. C:\Users\alexander.ruehl) for the volume parameter?
You can use relative path for your volume : --volume="./mydata:/root/data"
Also make sure that you have given the permission for read/write to Docker.

My boot2docker installation seems to not be working. What am I doing wrong?

I'm running on Mac OS X 10.6.8 Snow Leopard.
FYI: I can't upgrade my OS so that is not an option for me right now.
So, I install boot2docker and when I go click on the icon I receive the following output:
username#My-Mac:~$ bash
username#My-Mac:~$ unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH
username#My-Mac:~$ mkdir -p ~/.boot2docker
username#My-Mac:~$ if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi
username#My-Mac:~$ /usr/local/bin/boot2docker init
/usr/local/bin/boot2docker up
$(/usr/local/bin/boot2docker shellinit)
docker version
error in run: Failed to initialize machine "boot2docker-vm": exit status 1
username#My-Mac:~$ /usr/local/bin/boot2docker up
error in run: Failed to get machine "boot2docker-vm": machine does not exist (Did you run `boot2docker init`?)
username#My-Mac:~$ $(/usr/local/bin/boot2docker shellinit)
error in run: Failed to get machine "boot2docker-vm": machine does not exist (Did you run `boot2docker init`?)
username#My-Mac:~$ docker version
Client version: 1.6.0
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 4749651
OS/Arch (client): darwin/amd64
FATA[0000] Get http:///var/run/docker.sock/v1.18/version: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
username#My-Mac:~$
What does this mean? How can I fix this?
I ran into the same issue. You need to set the environment variables in your shell. Run the following:
eval "$(boot2docker shellinit)"
Since it is only persistent per shell you'll need to add it to your ~/.bashrc, ~/.bash_profile, .zshrc, or whatever other shell profile you need it to run in.
Here is a good example of a plist for auto starting boot2docker. You'll have to modify the plist so the working directory matches yours. https://gist.github.com/krak3n/0f7fe4c3c5828767ec5b
I've installed Kitematic (Version 0.5.19 which is Beta as of this writing) as well as boot2docker on my system. Kitematic does not install a plist for auto starting your boot2docker instance. It boots when you start Kitematic. It most likely shuts it down on close which means your containers that are running will shutdown as well.
Ultimately it is up to how you want to setup and run your environment. If you're going only boot2docker and docker CLI and want things running at boot, create the plist and set your .bash_profile/.zshrc. If you want a GUI and CLI option that only boots and runs when you want it to then Kitematic is the way to go.
The answer above is correct, but you don't need the eval, you can just use:
$(boot2docker shellinit)
You can put this in your .profile
echo '$(boot2docker shellinit)' >> ~/.profile
and then it is setup every time you create a new shell.
This might be a duplicate of a previous question I answered:
Docker TLS error on Mac
After much hassle and delegation I was able to finally figure out what was going on. It was xanderlopez in this post that got me to realize that the problem lied with my shared folder and virtual machine folder locations for VitualBox. After changing the shared folder and renaming the location for the VM to "VirtualBox VMs", once I reinstalled boot2docker, everything ran as was supposed to and the hello world verification succeeded. So that's a gotcha right there. The location of your vm must be inside a folder named "VirtualBox VMs". The location seems to be unimportant as I just created a subfolder folder inside the folder that I was already using. Not sure how that works but it seems to have worked which is good enough for this issue. If I see any problems up ahead later related to the folder structure I'll be sure to reference this post.

Resources