本文介绍了Docker通过entrypoint.sh传递参数Docker Entrypoint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将参数传递给docker入口点,但失败了,
这些是我遵循的步骤

I tried to pass an argument to my docker entry point , but it fails ,these are steps i followed

Docker Build Command : docker build -t "DBDNS" --build-arg  db=sample

在Dockerfile中

In Dockerfile

ARG db
ENV database ${db}
ENTRYPOINT ["/docker/entrypoint.sh", ${db}]


bash的错误:1:bash: [/var/www/html/.docker/entrypoint.sh ,:找不到

Error for thisbash: 1: bash: [/var/www/html/.docker/entrypoint.sh,: not found

实际上文件存在,并为entrypoint.sh传递了一个参数,从而导致问题。
与此相关的任何线索

Actually file exists and passing an argument for entrypoint.sh causing issue.Any clues for this

-----------ENTRYPOINT---------------------
#!/usr/bin/env bash

echo "Entrypoint stuff"
echo "----------------"
echo "NEW APP DB CLONE FROM  $1"
echo "sites/files permission changes"
echo "--------------------------------------"


推荐答案

Entrypoint不能具有a变量。您可以将其移至CMD或直接在 docker-entrypoint.sh

Entrypoint cannot have a a variable. You can either move it to CMD or directly access it in docker-entrypoint.sh

ARG db
ENV database ${db}
ENTRYPOINT ["/docker/entrypoint.sh"]
CMD ["${db}"]


-----------ENTRYPOINT---------------------
#!/usr/bin/env bash

echo "Entrypoint stuff"
echo "----------------"
echo "NEW APP DB CLONE FROM  $1 or same as $database"
echo "sites/files permission changes"
echo "--------------------------------------"

即使您不使用CMD , $ database 将为您提供所需的价值

Even if you don't use CMD, $database will get you the value you need

这篇关于Docker通过entrypoint.sh传递参数Docker Entrypoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 11:10