问题描述
我要运行这样的docker容器:
I want to run a docker container like this:
docker run --rm -it -v volume1:/target -v volume2:/backup duplicity-image backup-label
这将导致以下入口点被执行:
This would cause the following Entrypoint do get executed:
duplicity /target file:///backup/$backup-label
所以我的问题是如何构造ENTRYPOINT以便它可以解析$backup-label
以及如何在其中传递backup-label
...我是否需要在其周围使用单引号... ...?
So my question is how do I structure the ENTRYPOINT such that it can resolve the $backup-label
and how do I pass the backup-label
in ... Do I need single quotes around it ... a dash in front of it ...?
TIA,奥莱(Ole)
TIA,Ole
推荐答案
当图像中包含ENTRYPOINT
脚本时,该脚本将接收docker run
命令行中图像之后传递的所有参数.也就是说,如果您有:
When you have an ENTRYPOINT
script in your image, that script will receive any arguments passed after the image on the docker run
command line. That is, if you have:
ENTRYPOINT /path/to/my/script.sh
然后您运行:
docker run myimage one two three
您的ENTRYPOINT
脚本将被命名为:
/path/to/my/script.sh one two three
从那时起,就像编写任何其他带参数的shell脚本一样:
From that point on, it's just like writing any other shell script that takes arguments:
#!/bin/sh
backup_label=$1
duplicity /target file:///backup/$backup_label
这篇关于在Docker Entrypoint中引用动态参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!