J'ai mon docker-registry dans localhost et je peux tirer/pousser avec la commande: docker Push localhost:5000/someimage
Comment puis-je le pousser avec une commande comme docker Push username@password:localhost:5000/someimage
?
Cette solution a fonctionné pour moi: J'ai tout d'abord créé un registre de dossiers à partir duquel je voulais travailler:
$ mkdir registry
$ cd registry/
Maintenant, je crée mon dossier dans lequel je vais stocker mes identifiants
$ mkdir auth
Maintenant, je vais créer un fichier htpasswd à l'aide d'un conteneur de menu fixe. Ce fichier htpasswd contiendra mes informations d'identification et mon mot de passe crypté.
$ docker run --entrypoint htpasswd registry:2 -Bbn myuser mypassword > auth/htpasswd
Vérifier
$ cat auth/htpasswd
myuser:$2y$05$8IpPEG94/u.gX4Hn9zDU3.6vru2rHJSehPEZfD1yyxHu.ABc2QhSa
Les informations d'identification sont bien. Maintenant, je dois ajouter mes informations d'identification à mon registre. Ici, je vais monter mon répertoire auth dans mon conteneur:
docker run -d -p 5000:5000 --restart=always --name registry_private -v `pwd`/auth:/auth -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" registry:2
TESTER:
$ docker Push localhost:5000/busybox
The Push refers to a repository [localhost:5000/busybox]
8ac8bfaff55a: Image Push failed
unauthorized: authentication required
authentifier
$ docker login localhost:5000
Username (): myuser
Password:
Login Succeeded
Réessayer la poussée
$ docker Push localhost:5000/busybox
The Push refers to a repository [localhost:5000/busybox]
8ac8bfaff55a: Pushed
latest: digest: sha256:1359608115b94599e5641638bac5aef1ddfaa79bb96057ebf41ebc8d33acf8a7 size: 527
Les informations d'identification sont enregistrées dans ~/.docker/config.json:
cat ~/.docker/config.json
{
"auths": {
"localhost:5000": {
"auth": "bXl1c2VyOm15cGFzc3dvcmQ="
}
}
N'oubliez pas qu'il est recommandé d'utiliser https lorsque vous utilisez des informations d'identification.
essayez de définir ceci dans votre fichier conf de docker ~/.docker/config.json
{
"auths": {
"https://localhost:5000/someimage": {
"auth": "username",
"email": "password"
}
}
}