Text of forums.docker.com › t › issue-with-github-access-tokens › 127723 as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Issue with github access tokens - Docker Hub - Docker Community Forums

Issue with github access tokens Docker Hub build crooksey201 (Crooksey201) August 11, 2022, 2:43pm 1 So I have a dockerfile that contains the code: ARG git_personal_token ENV git_personal_token $git_personal_token RUN git clone https://crooksey:${git_personal_token}@github.com/crooksey/myrepo.git (The ENV # line is not required locally, but have added as some Docker guides suggest its required, still fails with same reasons.) I can also try using $git_personal_token without the {} and again works locally, not on dockerhub.

I then build my Dockerfile locally with: $ docker build -t mycontainer:v0 . --build-arg git_personal_token=ghp_MYPERSONALACCESSTOKEN This works fine on a few local machines, but the code in Dokcerhub causes the error: #20 [ 9/17] RUN git clone https://crooksey:${git_personal_token}@github.com/crooksey/myrepo.git #20 0.370 Cloning ... #20 1.361 remote: Invalid username or password. On my dockerhub build settings, I do have “git_personal_token” in my build environment variables.

Screenshot from 2022-08-12 07-11-14 1083×267 11.8 KB This does not work, but If I update the Dockerfile to include a hard-coded access token, it builds correctly. RUN git clone https://crooksey:ghp_MYPERSONALACCESSTOKEN@github.com/crooksey/myrepo.git Seems very strange and I can’t work out why this might be, could my builds somehow be ignoring my build environment variables? meyay (Metin Y.) August 11, 2022, 4:43pm 2 Just to be sure: your build hook uses the argument --build-arg git_personal_token=${git_personal_token} to pass the build environment variable into the image build?

In case of unclearity, please share the content of hooks/build as it will help to understand what you actualy use to build the image. crooksey201 (Crooksey201) August 12, 2022, 6:14am 3 I have updated the original post to include more details. meyay (Metin Y.) August 12, 2022, 4:08pm 4 Shouldn’t it be like this? docker build --build-arg git_personal_token=${git_personal_token} -t mycontainer:v0 . Also I strongy suggest to remove the ENV, as it would persist your personal token in the image history and would be available in every contaiener created from that image.

Related topics Topic Replies Views Activity Authenticate to repo from image build Image Builds 2 4432 May 4, 2022 Can not use build environment variables configured on docker hub builds Docker Hub build , ci_cd 0 1041 October 21, 2019 Can't pass gitlab user defined variable through Docker image through --build-arg General docker 3 206 March 5, 2026 Docker Hub Build Parameters Docker Hub dockerhub , build 1 1569 September 26, 2016 Github credentials Docker Desktop dockerhub , docker , build 0 1445 January 19, 2018