简体   繁体   中英

Docker Container Volume not Mount with Host System

I am trying to mount my blackbox exporter config with host but its give me error.

blackbox-exporter    | level=info ts=2020-12-24T11:07:45.378Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:45.378Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:45.378Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:07:47.350Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:47.351Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:47.351Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:07:48.748Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:48.749Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:48.750Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:07:49.810Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:49.810Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:49.810Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:07:51.169Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:51.169Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:51.169Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:07:53.325Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:53.325Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:53.325Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:07:57.099Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:57.099Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:57.099Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter exited with code 1
blackbox-exporter    | level=info ts=2020-12-24T11:07:45.378Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:45.378Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:45.378Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:07:47.350Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:47.351Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:47.351Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:07:48.748Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:48.749Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:48.750Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:07:49.810Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:49.810Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:49.810Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:07:51.169Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:51.169Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:51.169Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:07:53.325Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:53.325Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:53.325Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:07:57.099Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:07:57.099Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:07:57.099Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:08:04.049Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:08:04.049Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:08:04.049Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"
blackbox-exporter    | level=info ts=2020-12-24T11:08:17.378Z caller=main.go:212 msg="Starting blackbox_exporter" version="(version=0.18.0, branch=HEAD, revision=60c86e6ce5a1111f7958b06ae7a08222bb6ec839)"
blackbox-exporter    | level=info ts=2020-12-24T11:08:17.378Z caller=main.go:213 msg="Build context" (gogo1.15.2,userroot@53d72328d93f,date20201012-09:46:31)=(MISSING)
blackbox-exporter    | level=error ts=2020-12-24T11:08:17.378Z caller=main.go:216 msg="Error loading config" err="error reading config file: open /etc/blackboxexporter/config.yml: no such file or directory"

Here is my Docker Compose file:

  blackbox_exporter:
    image: prom/blackbox-exporter
    container_name: blackbox-exporter
    volumes:
      - /etc/blackboxexporter/:/home/huzaifakhan/dockprom/prometheus/
    command:
      - '--config.file=/etc/blackboxexporter/config.yml'
    restart: unless-stopped
    dns: 8.8.8.8
    expose:
      - 9115
    networks:
      - monitor-net
    labels:
      org.label-schema.group: "monitoring"

In the volumes: section in your docker-compose file, switch the places of the directories. The host directory should come first, then the container directory.

AND, the config.yml must exist in the host directory. Just copy and paste it to the host from the container by running:

docker exec <container-name> cat /etc/blackboxexporter/config.yml

Basically, in the end, it should look like this:

volumes:
    - /home/.../your-directory:/etc/container-directory

/home/.../your-directory should contain the config.yml file

If this is the case, you will have the config file in the /etc/container-direcory when it is running and won't get the error above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM