I'm trying to take a shell script we use at work to set up our development environments and re-purpose it to work on my Windows environment via Git Bash.
The way the containers are brought up in the shell script are as follows:
docker run \
--detach \
--name=server_container \
--publish 80:80 \
--volume=$PWD/var/www:/var/www \
--volume=$PWD/var/log/apache2:/var/log/apache2 \
--link=mysql_container:mysql_container \
--link=redis_container:redis_container \
web-server
When I run that as-is, it returns the following error message:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: invalid bind mount spec "/C/Users/username/var/docker/environments/development/scripts/var/log/apache2;C:\\Program Files\\Git\\var\\log\\apache2": invalid volume specification: '/C/Users/username/var/docker/environments/development/scripts/var/log/apache2;C:\Program Files\Git\var\log\apache2': invalid mount config for type "bind": invalid mount path: '\Program Files\Git\var\log\apache2' mount path must be absolute. See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.
I did a bunch of googling and documentation reading, but I'm a little overwhelmed by Docker, and I think I got it wrong. I tried setting up the container as follows:
docker run \
--detach \
--name=server_container \
--publish 80:80 \
--volume=/c/users/username/var/www:/var/www \
--volume=/c/users/username/var/log/apache2:/var/log/apache2 \
--link=mysql_container:mysql_container \
--link=redis_container:redis_container \
web-server
It still errors out with a similar error message. If I remove the colon:/var/www it comes up, but it doesn't seem to map those directories properly, that is it doesn't know that C:\users\username\var\www
= /var/www
I know I'm missing something painfully dumb here, but when I look at the documentation I just glaze over. Any help would be greatly appreciated.
Volumes are stored in a part of the host filesystem which is managed by Docker ( /var/lib/docker/volumes/ on Linux). Non-Docker processes should not modify this part of the filesystem. Volumes are the best way to persist data in Docker.
Docker volumes are file systems mounted on Docker containers to preserve data generated by the running container. The volumes are stored on the host, independent of the container life cycle. This allows users to back up data and share file systems between containers easily.
There are two types of volumes to consider: Named volumes have a specific source from outside the container, for example, awesome:/bar . Anonymous volumes have no specific source, therefore, when the container is deleted, you can instruct the Docker Engine daemon to remove them.
If you want to make the path relative, you can use pwd and variables. For example:
CURRENT_DIR=$(pwd)
docker run -v /"$CURRENT_DIR"/../../test/:/test alpine ls test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With