Open jekkos opened 8 years ago
@jekkos When you run the stack in Docker Cloud, the file that you are going to mount should be in the node where your mysql container actually runs. Do you have such a file on the node? If not, docker daemon will simply create an empty folder.
Hi there,
Indeed that will be the issue. On the other hand I would like to know if there is a way to export a single sql script from another image and mount it into the mysql in this case? Or can this only be done for directories?
Problem is that I can't export the whole directory as a volume from my web container otherwise mysql will try to execute them all
In docker compose I can mount the file directly from the daemon's context.. but in this case the context isn't there of course and the single file should be picked from the other image.
you can put the the file in another container with volume:/docker-entrypoint-initdb.d/database.sql
and in your mysql, do a volume-from
Ok thanks for pointing that out. In that case I'll have to copy the script to another folder first in the web container.. which isn't necessary with docker compose as there I can map the volume to another path in the mysql container.
Ok I tried this way but now I get a circular dependency.. Guess I'll need to rebuild the mysql image in that case with my file in it? Or is there a better way to solve this kind of problem?
Alternatively, you can create an image that copy the file to the remote node first. Then, you should be able to run your compose without any changes.
Is there an easy way then to copy a file from an image to the host filesystem in a Dockerfile? So in this case I should just add a new Dockerfile to my project which contains only this file and then a command to copy it to the host filesystem?
Ok I thought this was bad practice I could use a docker cp command to copy to the host but I guess that needs to be done outside of the docker cloud stack file.. I would like that file to be selfcontained so users can deploy my app using just one click
You can put your script only, say S3, can let your mysql container download it at launch time.
If content of the sql script is fixed, you can also embed the script in your sql container.
Same issue on Debian:
Starting rsnapshot_localhost_data
Starting rsnapshot_localhost_scripts
ERROR: for scripts Cannot start service scripts: oci runtime error: rootfs_linux.go:53: mounting "/var/lib/docker/devicemapper/mnt/563175ea4e1af1627a69b46d7b1fe7f0351572071442127adad65230900b8292/rootfs/etc/rsnapshot.conf" to rootfs "/var/lib/docker/devicemapper/mnt/563175ea4e1af1627a69b46d7b1fe7f0351572071442127adad65230900b8292/rootfs" caused "not a directory"
$ hostnamectl
Operating System: Debian GNU/Linux stretch/sid
Kernel: Linux 4.1.0-1-amd64
Architecture: x86-64
$ docker --version
Docker version 1.12.0, build 8eab29e
$ docker-compose --version
docker-compose version 1.8.0, build f3628c7
When trying to deploy a stack with mysql image, I want to mount just one file (sql script) inside of the mysql docker container. This web:
works both in docker and docker-compose, but not in docker-cloud.
Instead it just create a directory
See also docker/compose#424