Docker Compose
Docker-compose is a tool used to define and run multiple container docker applications. It uses YAML files to configure the application’s services. You can then run a single command to create and start all the services defined in your configuration.
In this example we have created a docker-compose.yml file to create and run both influxdb and grafana. It has been configured to link grafana to influxdb and to start both container services automatically.
Pre-req
Linux OS installed (Debian used in this example)
Docker engine
Install docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Make executable
sudo chmod +x /usr/local/bin/docker-compose
Create docker-compose.yml
Create a file called docker-compose.yml with the text below to create and run influxdb and grafana containers.
influxdb:
image: influxdb
container_name: influxdb
ports:
- “8086:8086”
- “8083:8083”
- “8090:8090”
restart: unless-stopped
volumes:
- /srv/docker/influxdb/data:/var/lib/influxdb
grafana:
image: grafana/grafana
container_name: grafana
port:
- “3000:3000”
restart: unless-stopped
user: “0”
links:
- influxdb
volumes:
- /srv/docker/grafana/data:/var/lib/grafana
Run docker-compose
Execute docker-compose and start the container services as a daemon (-d).
docker-compose up -d