I'm using Windows 10 and Docker version 18.03.1-ce, build 9ee9f40.
I'm trying to do docker run -it --volume="./Users:/app" ubuntu:16.04 or docker run -it -v Users:/app ubuntu:16.04 but it's not working, my directory in Docker still empty.
I have read this post and it doesn't help.
UPD: Solved.
Important step was to go to Docker Settings > Shared Drives and uncheck and check your shared drive again.
Then you can mount your volume like this:
docker run -v /host_mnt/c/Users/User/Path:/docker/path image
This command should fix it .
docker run -it -v ${PWD}:/app ubuntu:16.04
Not sure what error you got, so I am assuming
your host directory may not be correct.(solution is based on this)
Permission issue.
Please check the permissions of your folders and user permission
Related
I'm trying to mount a directory in /tmp to a directory in a container, namely /test. To do this, I've run:
docker run --rm -it -v /tmp/tmpl42ydir5/:/test alpine:latest ls /test
I expect to see a few files when I do this, but instead I see nothing at all.
I tried moving the folder into my home directory and running again:
docker run --rm -it -v /home/theolodus/tmpl42ydir5/:/test alpine:latest ls /test
at which point I see the expected output. This makes me thing I have mis-configured something and/or the permissions have bitten me. Have I missed a step in installing docker? I did it via sudo snap install docker, and then configured docker to let me run as non-root by adding myself to the docker group. Running as root doesn't help...
Host machine is Ubuntu 20.04, docker version is 19.03.11
When running docker as a snap...
all files that Docker uses, such as dockerfiles, to be in $HOME.
Ref: https://snapcraft.io/docker
The /tmp filesystem simply isn't accessible to the docker engine when it's running within the snap isolation. You can install docker directly on Ubuntu from the upstream Docker repositories for a more traditional behavior.
If i have inside my localhost a log folder at:
/var
/logs
apache.logs
elasticsearch.logs
etc...
And i want to mount /var/logs directory of my host, into a path inside a Docker container, like /usr/var/logs/ , how do i do that within a dockerfile ? So each time a log file is updated, it would be accessible within the container too.
Thank you
You can not mount a volumn in Dockerfile
Because:
Dockerfile will build an image, image is independent on each machine host.
Image should be run everywhere on the same platform for example on linux platform it can be running on fedora, centos, ubuntu, redhat...etc
So you just mount volumn in to the container only. because container will be run on specify machine host.
Hope you understand it. Sorry for my bad English.
You can achieve it in two ways - https://docs.docker.com/storage/bind-mounts/
--mount
$ docker run -d -it --name devtest --mount type=bind,source=/var/logs,target=/usr/var/logs image:tag
-v
$ docker run -d -it --name devtest -v /var/logs:/usr/var/logs image:tag
Try -v option of docker run command.
docker run -itd -v /var/logs:/usr/var/logs image-name
This will mount /var/logs directory of host on to /usr/var/logs directory of container.
Hope this helps.
Update:
To mount directory with source and dest in dockerfile make use of this hack (Not 100% sure though).
RUN --mount=target=/usr/var/logs,type=bind,source=/var/logs
Why is this simple docker command is not mapping volume for me?
docker run -dit -v ./home:/home ubuntu bash
i have also tried this command and it also didn't work.
docker run -dit -v ./home:/var/www/html linode/lamp bash
i have seen others mapping volumes like this but it is not working for me. i'm running docker on windows 10 desktop. do i need to create 'home' foler or this command will also create 'home' folder for me.? please help. thank you
I can run docker container with ghost with this command (https://hub.docker.com/_/ghost/):
docker run -ti -v /tmp/data:/var/lib/ghost/content -p2368:2368 ghost
But only when /tmp/data is empty. If I try to stop this container with Ctrl+c and run it again, it fails with this error:
docker run -ti -v /tmp/data:/var/lib/ghost/content -p2368:2368 ghost
chown: changing ownership of '/var/lib/ghost/content/themes/casper': No such file or directory
I need to store ghost's data outside container and this is the way based on documentation. Am I missing something?
I'm trying this on Mac.
I had same problem when running ghost under Docker for Mac.
I would suggest to create docker volume for your data, rather than mounting direct folder. There seems to be a problem with resolving symlinks.
docker volume create ghost-data
docker run -it --mount source=ghost-data,target=/var/lib/ghost/content -p 2368:2368 ghost
i had this problem before but when i pull the latest version (docker pull ghost:latest) again everything work fine,,, i guess the chown on the ghost image Dockerfile made the ownership error....
I have problems with the introduction of these instructions https://github.com/notabenoid/notabenoid-dockerfile
Out my error command
docker run -v `pwd`:/srv/example.com -p 127.0.0.1:8080:80 --name notabenoid notabenoid
I managed to turn the site, but my goal is to change a few files and pictures
How to edit files to container ?
use docker execto modify some files in a container, see the doc
https://docs.docker.com/engine/reference/commandline/exec/
check also the docs for docker run
https://docs.docker.com/engine/reference/commandline/run/
and the examples with -v
If You only need to change some files use docker cp.
docker run -p 127.0.0.1:8080:80 --name notabenoid notabenoid
docker cp notabenoid:/srv/example.com/file_to_change .
edit file
docker cp file_to_change notabenoid:/srv/example.com/file_to_change
where /srv/example.com/file_to_change is a path to file in container.
edit
Let's Your new logo is /home/Hellioob/new_logo.gif.
docker cp /home/Hellioob/new_logo.gif notabenoid:/notabenoid/site/www/i/logo.gif