Mounting a file using volume
The configuration file has been created and will be mounted by using bind mounts. A bind mount enables us to mount a file on the workstation running Docker Engine to the Docker container. When using Compose, bind mounts are defined in the volumes
sections. This might be confusing since it’s in the same section as volumes
; however, it’s a bind mount.
We will mount the Redis configuration file to the container and alter entrypoint
:
services: redis: image: redis ports: - 6379:6379 entrypoint: ["redis-server","/usr/local/etc/redis/redis.conf"] labels: - com.packtpub.compose.app=task-manager volumes: - ./redis.conf:/usr/local/etc/redis/redis.conf ...