Docker Passing an argument Docker Entrypoint with

2020-07-24 05:43发布

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

In Dockerfile

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

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

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 "--------------------------------------"

标签: docker devops
1条回答
趁早两清
2楼-- · 2020-07-24 06:46

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 "--------------------------------------"

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

查看更多
登录 后发表回答