Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
155 views
in Technique[技术] by (71.8m points)

bash - Regarding passing file as env variable in docker container

I am trying to start a VGS satellite container as mentioned here

But I also need to pass a environment variable SATELLITE_ROUTES_PATH, which is also a filepath in local data folder.

docker run --rm -v data:/data -p 8089:8089 -p 9098:9098 -p 9099:9099 -e SATELLITE_ROUTES_PATH=/data/httbin.yml verygood/satellite     
Usage: app.py [OPTIONS]
Try 'app.py --help' for help.

Error: Invalid value for '--routes-path': File '/data/httbin.yml' does not exist.

How to resolve this issue, where I want to pass a VGS file while running container?

question from:https://stackoverflow.com/questions/65950057/regarding-passing-file-as-env-variable-in-docker-container

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When you bind a volume using docker, the host directory path cannot be relative:

This won't work:

-v data:/data

Change to a absolute path like -v ~/Downloads/data:/data or -v /home/user/Downloads/data:/data

If still you see the same error, make sure the file httbin.yml exists in out data folder


Note: The -v flag is very flexible. It can bindmount or name a volume with just a slight adjustment in syntax. If the first argument begins with a / or ~/, you’re creating a bindmount. Remove that, and you’re naming the volume.

  • -v /path:/path/in/container mounts the host directory, /path at the /path/in/container
  • -v path:/path/in/container creates a volume named path with no relationship to the host.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...