For the docker image v2tec/watchtower
I must provide the user-specific docker configuration file config.json
. I am currently doing this as following:
version: "3"
services:
watchtower:
image: v2tec/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/thefrozenyoghurt/.docker/config.json:/config.json
This works on my machine. But I want to distribute this docker-compose.yml
to my colleagues so they can use it also. This won't work with the docker-compose.yml
above, as my home directory is hardcoded.
Is it possible to refer to the user home directory in a docker-compose.yml
? I cannot find such functionalities in the documentation. I think I need something like:
version: "3"
services:
watchtower:
image: v2tec/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- $HOME/.docker/config.json:/config.json
We can also create a volume with Docker compose service or also specify existing volumes. For example, the following screenshot shows a 'docker-compose' file that creates a docker-compose service with a volume. As a result of the above command, a volume with the name 'myvolume' gets created.
These volumes are created inside /var/lib/docker/volume local host directory. As we can see, we don't have to specify the host directory. We just need to specify the directory inside the container. If we remove the volume instruction from the docker-compose.
~/.docker/config.json
should work for this
version: "3"
services:
watchtower:
image: v2tec/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ~/.docker/config.json:/config.json
~
wasn't working for us, it was creating folder called something.json
, we fixed it like this:
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${HOME}/.docker/config.json:/config.json
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