Mapping windows directory to docker container by absolute path - windows

I'm trying to map windows folder to docker container. Path is C:/myfolder.
Using -v command line option works fine, but I'd like to do it using dockerfile.
RUN --mount=source="myfolder",target="/workspace/myfolder"
This works ok for local folder, but not if I specify an absolute path
RUN --mount=source="C:\myfolder",target="/workspace/myfolder"
This returns error "failed to compute cache key: "/c:myfolder" not found: not found"
I tried to use different path syntaxes, such as //c/myfolder and others, but always encounter error in docker build. Same result with relative paths such as "../myfolder", etc. What is the correct way of doing this?

Related

Mont a volume in host directoy

I am running an application with a dockerfile that I made.
I run at first my image with this command:
docker run -it -p 8501:8501 99aa9d3b7cc1
Everything works fine, but I was expecting to see a file in a specific folder of my directory of the app, which is an expected behaviour. But running with docker, seems like the application cannot write in my host directory.
Then I tried to mount a volume with this command
docker 99aa9d3b7cc1:/output .
I got this error docker: invalid reference format.
Which is the right way to persist the data that the application generates?
Use docker bind mounts.
e.g.
-v "$(pwd)"/volume:/output
The files created in /output in the container will be accessible in the volume folder relative to where the docker command has been run.

CLI Go Config.toml file location

I am attempting to test a Golang application hauser locally on via -bash CLI before deploying on a VM.
Per the documentation, I compiled locally and copied the example-config.toml file. I then mapped to the GOPATH and opened hauser.exe to open config.toml file. However, when I execute, it returns open config.toml: no such file or directory
C02Z30ANLVDV:~ pmcgin2$ $GOPATH/bin/hauser -c Documents/go/bin/config.toml
2020/08/14 18:05:23 Cannot find folder , make sure it exists
C02Z30ANLVDV:~ pmcgin2$ open Documents/go/bin/config.toml
No application knows how to open /Users/pmcgin2/Documents/go/bin/config.toml.
Is there an alternative command I can execute to override the default config.toml location for an application like this?
There are two possibilities to solve your issue:
give an absolute path as argument:
$GOPATH/bin/hauser -c /Users/pmcgin2/Documents/go/bin/config.toml
give a relative path from the binary location:
$GOPATH/bin/hauser -c config.toml
Generally, it is easier to use absolute paths.

unable to prepare context: unable to evaluate symlinks in context path: EvalSymlinks: too many links error when installing libacvp on windows

I've been trying to use cisco's libacvp on my windows (10, 64 bit) computer for some time now. I have installed OpenSSL 1.1.1g and Docker (19.03.12).
While trying to run docker build -t libacvp_w_openssl111 . in cmd I've been getting the error unable to prepare context: unable to evaluate symlinks in context path: EvalSymlinks: too many links.
I looked through this post (which seemed to get a lot of attention) but the only solution that was found there was to check that the Dockerfile was in the correct directory (also relative to the current directory from cmd), with no file extension and capitalized correctly, which it was. Beyond that - no help.
Any thoughts?
Thanks
It looks you're executing docker build in a folder that has a lot of symlinks, some of them which are pointing out of current dir (unable to prepare context error message)
Try creating a new empty folder, copy Dockerfile there and execute again your docker build -t libacvp_w_openssl111 .
I had exactly the same problem but in my case it was a matter of long path where the Dockerfile was sitting. When I moved it to root folder of another drive it worked like a charm.

docker: Error response from daemon: Mounts denied:

Even though this question might look like a duplicate one, i seem to be having a peculiar problem here.
Scenario 1:The project folder in the /users directory
I get the below error when i tried to start my docker image:
docker: Error response from daemon: Mounts denied:
The path /users/myUserName/myApp/backend/build/pacts is not shared from OS X and is not known to Docker.
The exact same command passed a few days back and has suddenly stopped working
Scenario 2: The project folder is in the /Documents folder
The docker run command which threw the same error as Scenario 1 now somehow seems to work fine.
The docker preferences has /Users in the list of shared directories and still doesnt work.
(Image attached)
Docker preferences
Macos version : Mojave(10.14.6)
Note: Whenever the docker run command throws the error in Scenario 1, simply shifting the project to a new location (like /Downloads) seems to work fine.Even though this fixes the issue temporarily, i am curious to know why this error occurs even though the default preferences are as expected.
The path is case sensitive. The paths /users/myUserName/myApp/backend/build/pacts and /Users/myUserName/myApp/backend/build/pacts are different inside of docker while MacOS treats them as the same.
To fix, you likely need to cd /Users/myUserName/myApp/ before running your command.

How to use ssh key inside docker container

I am building dockerfile to create an image where I want to build a package. I want to pull this package inside the docker image. I need to do a git clone for that. I saw the discussion on this post :
Using SSH keys inside docker container
Based on that, here is the content in my Dockerfile :
ENV SSH_HOME /Users/myid
ADD $SSH_HOME/.ssh/id_rsa /root/.ssh/id_rsa
RUN echo " IdentityFile ~/.ssh/id_rsa" >> /etc/ssh/ssh_config
When I run docker build, I am getting an error due to relative path. If I provide absolute path, it says the location is outside of context. Any idea how to fix this? I am running on Mac OSX 10.
With the script above, I am getting the following error :
ADD failed: stat /var/lib/docker/tmp/docker-builder6164655/Users/myid/.ssh/id_rsa: no such file or directory
Looks like it might be related to this bug here
The broken example is very similar to your path problem:
# Dockerfile
FROM ubuntu:14.04
COPY start.sh /start.sh
# comes back with:
stat /var/lib/docker/aufs/mnt/e89417ccaafbc91c3f930b56819427f83b3f2d3b3a246fbd6b48c9abcc7233f6/start.sh: no such file or directory
I'd try
updating to the most recent docker
restarting your docker engine

Resources