New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The data volume causes the container directory to be overwritten. #4581
Comments
If you mount your local directory into What are you trying to do? |
I want to synchronize the items in the container webapps to the host. |
Do not know how to use the data volume. |
Are you saying the contents of |
./tomcat/webapps folder is normal, but inside the file. Not synchronized. |
/ Usr / local / tomcat / webapps inside the file is not synchronized to ./tomcat/webapps. |
This is the normal behavior :) If you mount a local directory on a container directory, the container directory is hidden and replaced by your local. The logs files will written after the start of a container, in your local directory. If you comment the second line withg your logs, the container write always in the same place for it but neither in your local directory. |
I think what @nicodmf is saying, is (correct me if I'm wrong, obv.):
If host './tomcat/webapps' is not empty, it will overwrite container files, and be shared. It's /meant/ to depend on the host folder being empty. I'm specifically having an issue where the folder is empty, but isn't getting the container files copied to it. (^ I was conflating 'named volumes' with 'mount binds') -- I've come full circle and have realised I was expecting behaviour from Docker volumes that didn't exist at the time. This is the behaviour I wanted, which was missing:
Now using a named volume, that is accessible via the host. I would be interested to see metrics comparing a bash script to copy from container -> host, vs named volumes, I swear it is slightly slower using named volumes... |
@mikeyjk hey is there any solution to this or ticket to follow?. I was uploading some images for my work and I realized that all the readmes and tutorials I was doing were wrong because the spec mentioned in the docs from Docker is not accurate. When the host codebase is empty, the container doesn't copy anything. |
@dantebarba There are a /few/ tickets that are kind of related to this, but my issue was more of a comprehension problem understanding the behaviour of bind mounts vs named volumes. What I wanted was a named volume, but I thought I wanted a bind volume. It is possible the Docker docs have gotten this wrong or worded it strangely, can you link me / copy the relevant docs? Docker is still 'relatively' new, so there are still things to be ironed out. So damn useful though. |
Seems like this was some confusion over the behaviour of volume vs binds which mikeyjk has explained. I'm going to close, if there is still confusion please do reopen. |
I know this was closed a while ago, but I'm running into an issue where my named volume is overwriting my docker file path, even when the host volume does not exist.
In this case it is causing the /app folder in my docker container to be empty, because it created an empty librespeed-vol folder on my local host. From my understanding of how volumes work (and how it worked initially for me) docker compose should create the volume (librespeed-vol) and sync the files from the container (/app) to the volume path on the initial creation. Not sure what I'm doing wrong here, but hoping it's a simple fix. |
@kitanog I don't think docker is supposed to do that. In your yaml you are binding the directory /docker_configs/librespeed-vol from your host and you are also creating a volume called librespeed-vol which is empty and not binded. I don't think docker-compose nor docker will understand that you want to copy the directory contents into a new volume. Feel free to comment and quote the docs if you need so. |
Adding the first line causes the file in the container to be removed.
Log file synchronization is normal.
Commented out webapps tomcat is normal.
This question is very strange, I do not know how to solve.
Or other ways to solve.
The text was updated successfully, but these errors were encountered: