I am using a docker compose file with multiple services and named volumes.
How can I copy a file to such a named volume ?
I’ve achieved this in the past by using a start script in my Dockerfile. Have a look at the script in this application and see how it relates to the named volumes in the Docker compose file.
1 Like
I have found the issue.
Using COPY in the Dockerfile works if you deploy your application the first time.
It doesn’t seem to work if you have already deployed your application.
E.g. here below the contents of my Dockerfile
FROM arm32v7/telegraf:latest
COPY telegraf.conf /etc/telegraf
and here below the contents of my docker-complose.yml file:
version: '2'
volumes:
influx-data:
influx-config:
telegraf-config:
services:
influxdb:
image: arm32v7/influxdb:latest
volumes:
# Mount for influxdb data directory
- 'influx-data:/var/lib/influxdb'
# Mount for influxdb configuration
- 'influx-config:/etc/influxdb/'
ports:
# The API for InfluxDB is served on port 8086
- "8086:8086"
- "8082:8082"
# UDP Port
- "8089:8089"
restart: always
telegraf:
# Full tag list: https://hub.docker.com/r/library/telegraf/tags/
build : telegraf
volumes:
# Mount for telegraf configuration
- 'telegraf-config:/etc/telegraf'
pid: "host"
network_mode: "host"
privileged: true
labels:
io.resin.features.balena-socket: '1'
depends_on:
- influxdb
restart: always
grafana:
image: fg2it/grafana-armhf:v5.1.4
ports:
- "3000:3000"
links:
- influxdb
restart: always
1 Like
Thanks Chris,
You have proposed another solution in balena-io-playground/balena-sense/blob/master/grafana/start.sh
which also works if your application is already deployed and if multiple services are using the same named volume.