0

I want to create an image , with git pre-installed that can log in Github during docker-run.

This image suppose to get Github username and token in docker-run command through -e option.

For example :

sudo docker run -it --rm -e "username=parsalotfy" -e "token=secretsecretsecret" -e "[email protected]" gitloggedin

I wrote Dockerfile like this :

FROM alpine

RUN apk update
RUN apk upgrade
RUN apk add git
RUN git clone https://$username:[email protected]/$username/$repo.git
RUN cd $repo/
RUN git config user.email $email

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

But when I want to build this Dockerfile, this error occurs :

enter image description here

What am I doing wrong here?

And How can I have a Github user logged in passing username and password through -e option after docker-run ?

Thank you.

4
  • 1
    docs.docker.com/engine/reference/builder/… Commented Apr 26, 2020 at 0:21
  • @JosephSible-ReinstateMonica with ENV there is a default value ! Commented Apr 26, 2020 at 0:32
  • 1
    Are you willing to use DOCKER_BUILDKIT? Commented Apr 26, 2020 at 0:38
  • 1
    Inside the Dockerfile none of those variables are defined; the docker build command doesn't know what arguments the docker run will eventually be invoked with. For a couple of reasons I'd suggest checking out the source tree you're trying to build outside of the Dockerfile, and picking a specific filesystem path inside the image. Commented Apr 26, 2020 at 0:44

1 Answer 1

1

As someone mentioned the reference link in comments you'll need to declare your environment variables before use like ENV EMAIL [email protected] or just ENV EMAIL then using it

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.