3

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 "--------------------------------------"
Raza Rafaideen
  • 2,119
  • 1
  • 19
  • 30

1 Answers1

5

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

Raza Rafaideen
  • 2,119
  • 1
  • 19
  • 30
Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265