Error when running ghost docker image second time - docker

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....

Related

Trying to run "comitted" Docker image, get "cannot mount volume over existing file, file exists"

I am developing a Docker image. I started with a base image and was working inside it interactively, using bash. I installed a bunch of stuff, and the install (which included compiling a lot of code) took over 20 minutes, so to save my work, I used:
$ docker commit 0f08ac958391 myproject:wip
Now when I try to run the image:
$ docker run --rm -it myproject:wip
docker: Error response from daemon: cannot mount volume over existing file, file exists /var/lib/docker/overlay2/95aa9a9ea7cc0b1ba302adbd287e4d7059ee4fbe64183404df3bc65df332ee63/merged/run/host-services/ssh-auth.sock.
What is going on? How do I fix this?
Note about related/duplicate questions: while there are other questions about this error message, none of the answers directly explain why the error happens in this situation or what to do about it. In fact, most of the questions have no answers at all.
When I ran the base image, I included a mount for the SSH agent socket:
$ docker run --rm -it -v /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock myproject:dev /bin/bash
This bind mounts a file from the host (actually the Docker daemon VM) to a file in the Docker container. When I committed the running image, the image contained the file /run/host-services/ssh-auth.sock. The image also contained an empty volume reference to /run/host-services/ssh-auth.sock. This means that when I ran
$ docker run --rm -it myproject:wip
It was equivalent to running
$ docker run -v /run/host-services/ssh-auth.sock --rm -it myproject:wip
Unfortunately, what that command does is create an anonymous volume and mount it into the directory /run/host-services/ssh-auth.sock in the container. This works if the container has such a directory or even if it does not. What causes it to fail is if the target name is taken up by a file. Docker will not mount a volume over a file.
The solution is to explicitly provide a mapping from a host file to the target volume. Any host file will do, but in my case it is best to use the original. So this works:
docker run --rm -it -v /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock myproject:wip

Docker: error response from daemon: invalid mode: /tf

I'm new to using docker and my objective is to bind mount a docker image to a file path on my host machine (shown in the below directory) so I can:
Run a Jupyter Notebook instance without losing the data every time I end my terminal session
Link my Jupyter Notebook to the same path where my training data resides
I have tried at looking at many threads on the topic to little avail. I run the command shown below and am using Linux Mint:
sudo docker run -it --rm --gpus all -v "$(pwd):/media/hossamantarkorin/Laptop Data II/1- Educational/ML Training/Incident Detection/I75_I95 RITIS":"/tf" -p 8888:8888 tensorflow/tensorflow:2.3.0rc1-gpu-jupyter
What am I doing wrong here?
Thanks,
Hossam
This usually happens when docker is not running.
Try sudo service docker start before entering your command.
I just wanted to provide an update on this. The easiest way to work on your local directory is to:
Do a change directory to where you want to work
Run your docker while bind mounting to your pwd:
sudo docker run -it --rm --gpus all -v "$(pwd):/tf" -p 8888:8888 tensorflow/tensorflow:2.3.0rc1-gpu-jupyter

Plone on Docker always starts from scratch

I'm trying to develope Plone project with Docker, i have used this official image of Plone 5.2.0, the images is built a run perfectly with:
$ docker build -t plone-5.2.0-official-img .
$ docker run -p 8080:8080 -it plone-5.2.0-official-cntr
But the plone restarts each time i run the docker container asking to create the project from skratch.
Anybody could help me with this.
Thanks in advance.
You can also use a volume for data like:
$ docker run -p 8080:8080 -it -v plone-data:/data plone-5.2.0-official-cntr
The next time you'll run a new container it will re-use previous data.
If this helps,
Volumes are the docker way to persist data. You can read it up over here
When running the container just add a -v option and specify your path to store your data.
$ docker run -p "port:port" -it -v "path"
This is expected behavior, because docker run starts a new container, which doesn't have the state from your previous container.
You can use docker start CONTAINER, which will have the state from that CONTAINER's setup
https://docs.docker.com/engine/reference/commandline/start/
A more common approach is to use docker-compose.yml and docker-compose up -d, which will, in most cases, reuse previous state.
https://docs.docker.com/compose/gettingstarted/

Docker mount host volume Windows

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

Docker volumes not mounting

I am using this docker image ( https://hub.docker.com/r/karai17/lapis-centos/~/dockerfile/ ) and the following docker run script and it's not setting up my volumes. When I open the container with bash, both /var/www and /var/data are empty.
docker run -dti -p 8888:2808
-v "C:\Users\karai\Documents\GitHub\project\data:/var/data"
-v "C:\Users\karai\Documents\GitHub\project\www:/var/www"
--name project
karai17/lapis-centos:latest
This was working just the other day, the only changes I've made to the Docker image was to add a few more Lua Rocks. All of the data is 100% definitely there, so I am not sure what is going on.
Not sure what happened but after doing a factory reset of Docker for Windows, the issue has been resolved.

Resources