I'm trying to attach a volume to a docker container when it starts as a way of providing input to the docker container. When I type:
docker run swanijam/djredcap-harvest -v Users/swanickj/testFolder/Dock/Input:/Input
The Input folder never appears in the container.
I'm aware that there have been issues of boot2docker not having access to /Users but in my VirtualBox /Users is shared, as is default in boot2docker > 1.3.
The Input folder is being accessed in the ENTRYPOINT line of my Dockerfile, when it is built.
If you need me to show you any code or other files, please let me know!
Please pay attention to the path you are using. It should be:
docker run swanijam/djredcap-harvest -v /Users/swanickj/testFolder/Dock/Input:/Input
Boot2docker automatically mounts the /Users folders from your mac, and you should find it inside your boot2docker instance as:
cd /Users
Hope it helps you.
Related
I have a docker Mac host running an Ubuntu 19.10 guest. I am sharing a folder on my Mac filesystem that contains ~56,000 files totaling 230MB. When I ls that directory from within a docker container, it responds with:
Input/output error: <the directory name>
The folder is shared when I run the container via docker run -v /path/on/mac/fs:/path/in/guest -it my-image:latest /bin/bash.
When I ls the directory from a Mac shell, it works as expected.
Trying with a pared-down version of the directory (29k files) works as expected.
I have found a workaround: disabling "Use gRPC FUSE for file sharing" in the docker dashboard. ls works from within the container, but I still don't really understand the root of the problem.
56k files is not trivial, but also I wouldn't have guessed it's so big as to break docker.
So my questions:
Why might this be happening? Is this actually a gRPC issue, or something else?
Is there any documentation on gRPC FUSE limits? I couldn't find any.
I mounted a folder in docker ubuntu container
docker run -it --rm -v ${pwd}:/files ubuntu /bin/bash
but when i try to write to mounted folder get error
root#0974e91f50ec:/files# cat >a.txt
bash: a.txt: Permission denied
Is it possible to write to mounted folder?
I just tried your example. Here's what I ran on my windows machine.
And the file appears fine.
Also they appear fine in the host system (I created b.txt on the host to check if it appears fine in the container).
PS: Something you have to beware of is that on Windows you can only mount very specific directories (e.g. ~/Documents directory) at least when using Docker toolbox (Not sure about Docker Desktop CE). I think to mount folders from other directories there's bit of work to be done. So it might be a good idea to make sure that whatever you are trying to mount is in fact something allowed by your Docker on Windows.
I am trying to configure my Docker instance to allow insecure registries on my Mac. However, in the new installation for Docker, I can't find which config file to place the
--insecure-registry host:port
I see in some places to put it in the /etc/default/docker file, yet the folder default doesn't exist. I've even tried reating a docker file in the /etc/defaults dir to no avail.
I could really use some insight. Thanks.
Use docker-machine with the --engine-insecure-registry to accomplish this on Mac. If you initially created your machine with name dev you will need to stop and remove it first:
docker-machine stop dev
docker-machine rm dev
Then, assuming your registry was at registry.mydomain.internal:8443 you would create the new machine using:
docker-machine create -d virtualbox --engine-insecure-registry registry.mydomain.internal:8443 dev
Well using Kitematic on Windows and starting the container hello-world-nginx. I'm totally able to edit the file on Windows and see the modifications at the browser.
But when I create some image and try to edit the file (html), nothing happens.
Here's the command:
docker build -t a-example . && docker run --name a-example -i -t -v //c/Users/pablo/htdocs/www/a-example/src:/www -d -p 80:80 a-example
And here's my Dockerfile:
FROM nginx
RUN mkdir /etc/nginx/logs && touch /etc/nginx/logs/a-example.log
ADD ./nginx.conf /etc/nginx/conf.d/default.conf
ADD /src /www
VOLUME /www
Another question:
Is this message have something to do with?
SECURITY WARNING: You are building a Docker image from Windows against
a non-Win dows Docker host. All files and directories added to build
context will have '-r wxr-xr-x' permissions. It is recommended to
double check and reset permissions f or sensitive files and
directories.
I do not use KiteMatic or Docker Machine to control my local docker instance.
However, Docker Machine uses a boot2docker iso (customized version of Tiny Core Linux with Docker) running in a VirtualBox vm. Virtual Box provides guest Additions to mount host machine folders.
Refer to Boot2Docker guidelines at the time of Docker 1.9.1 release
Or the Docker Machine shares:
On Windows:
- C:\Users mounted as /c/Users
On Linux:
- /home mounted as /hosthome
On OSX:
- /Users mounted as /Users
which is done through Guest Additions:
vbm("sharedfolder", "add", d.MachineName, "--name", shareName, "--hostpath", shareDir, "--automount")
If you opt to use samba shares from your windows host instead, you will need the appropriate TLC packages (from the FAQ):
How do I mount windows shares?
If the sharing computer is at least Windows 2000, you can mount the share with only the filesystems-2.6.29.1-tinycore.tcz extension.
In a root console:
mkdir /mnt/windows
mount -t cifs //9.53.216.11/myshare /mnt/windows -o user=myname,pass=mypassword
And after searching for boot2docker and filesystems-2.6.29.1-tinycore.tcz I got to this GitHub issue:
sudo find / -type d -name 'cifs' seems to indicate that CIFS (Samba) client in the right kernel version is already there... allowing us to run
sudo mount -t cifs //MYPC/hostgithub ~/windows -o user=USER
on the boot2docker VM
Using Docker Volumes
It seems Docker Volumes are a new proposal for handling host folders for Developer Environments, see:
Docker-Volume-Netshare: Although this requires nfs-common or nfs-utils (depending on your distro) to be available on the docker machine, this may not work for CoreOS / Boot2Docker without some other tricks.
It should actually work on boot2docker considering how Docker-Volume-Netshare just wraps shell exec /bin/sh -c "mount -t cifs ..." command. If you use the so0k/mount.cifs_copy on CoreOS you may need a way to specify the path to cifs /opt/bin/mount.cifs.
For Windows users, note also my blog post using the netshare volume driver mentioned above to provision mounts from the Windows host across a Swarm Cluster.
Note: Be careful when using git-for-windows and git-bash as I'm having issues with these converting the paths I pass on to docker.exe
I don't think your volume is available so your container is displaying the static content from /src that you ADDed during the image build.
Kitematic runs a VirtualBox linux machine which runs your docker containers.
The path you have used for the volume: //c/Users/pablo/htdocs/www/a-example/src:/www looks suspect as that's the full windows path.
Docker machine (which is what kitematic uses underneath to manage the virutal machine) will map C:\Users to /Users by default
Try --volume /Users/pablo/htdocs/www/a-example/src:/www
I've just set up boot2docker on my Mac. How do I go about mounting a local directory on my Mac so that it's accessible all the way through to a running Docker container? Thanks for your help!
As of October 16, 2014, Docker supports mounting directories in the /Users path seamlessly.
From the Docker blog:
With this release we are addressing the most common issue: sharing directories between your Mac and your containers. Using Docker 1.3 with the corresponding version of boot2docker, host-mounted volumes now work the way you expect them to.
...Note that there are still some limitations: for example this feature is limited to boot2docker’s virtualbox configuration, cannot be managed dynamically, and only works for directories in /Users . But we are receiving exciting contributions to improve volume management, so expect this area to improve drastically in the next few releases.
Example usage:
$ docker run -v /Users/bob/myapp/src:/src [...]
boot2docker with share other than /Users
see https://github.com/boot2docker/boot2docker/issues/678.
Share your folder with the VM:
VBoxManage sharedfolder add boot2docker-vm --name /tmp/Work --hostpath /CODE --automount
Based on info found un bootscript.sh, you know that the VM will run a bootlocal.sh script that is in the /var/lib/boot2docker folder, where data persists.
Add a file /var/lib/boot2docker/bootlocal.sh
#!/bin/sh
# bash is not available!
mkdir -p /CODE
mount -t vboxsf /tmp/Work /CODE
Then chmod +x /var/lib/boot2docker/bootlocal.sh and reboot your boot2docker-vm vm.
boot2docker together with VirtualBox Guest Additions
How to mount /Users into boot2docker
https://medium.com/boot2docker-lightweight-linux-for-docker/boot2docker-together-with-virtualbox-guest-additions-da1e3ab2465c
tl;dr Build your own custom boot2docker.iso with VirtualBox Guest
Additions (see link) or download
http://static.dockerfiles.io/boot2docker-v1.0.1-virtualbox-guest-additions-v4.3.12.iso
and save it to ~/.boot2docker/boot2docker.iso.
As Levi mentioned, the /Users directory is auto-mounted. This is true in both boot2docker and docker-machine. That said, if you want to mount anything outside of /Users, all the current answers talk about Boot2docker. Since that's now deprecated in favor of docker-machine, this works for docker-machine:
First, ssh into the docker-machine vm and create the folder we'll be mapping to:
docker-machine ssh $MACHINE_NAME "sudo mkdir -p \"$VOL_DIR\""
Now share the folder to VirtualBox:
WORKDIR=$(basename "$VOL_DIR")
vboxmanage sharedfolder add "$MACHINE_NAME" --name "$WORKDIR" --hostpath "$VOL_DIR" --transient
Finally, ssh into the docker-machine again and mount the folder we just shared:
docker-machine ssh $MACHINE_NAME "sudo mount -t vboxsf -o uid=\"$U\",gid=\"$G\" \"$WORKDIR\" \"$VOL_DIR\""
Note: for UID and GID you can basically use whatever integers as long as they're not already taken.
This is tested as of docker-machine 0.4.1 and docker 1.8.3 on OS X El Capitan.