2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Error response from daemon: login attempt to https://registry.heroku.com/v2/ failed with status: 401 Unauthorizedの解決法

Posted at

環境

MacOS Big Sur 11.5.2
docker 20.10.6
heroku 7.59.1

CircleCIでのテスト中起こったエラーです。
config.ymlの中のHeroku loginでエラーになりました。

config.yml
version: 2.1
orbs:
  ruby: circleci/ruby@1.1.2
  heroku: circleci/heroku@1.2.3

jobs:
  build:
    docker:
      - image: circleci/ruby:3.0.2
    working_directory: ~/minoirominori
    steps:
      - checkout:
          path: ~/minoirominori
      - ruby/install-deps
      - run:  wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
      - run:  bash .circleci/setup-heroku.sh
      - add_ssh_keys:
          fingerprints: 
          - "SHA256:8whK7z7k7uhcgyvbVuKBmiRzJRMbxYTwK6pwTHG13Rs "

  test:
    docker:
      - image: circleci/ruby:3.0.2
      - image: circleci/mysql:8.0
        environment:
          MYSQL_ROOT_PASSWORD: password
          MYSQL_DATABASE: rails-front-demo-db
    environment:
      BUNDLE_JOBS: "3"
      BUNDLE_RETRY: "3"
      APP_DATABASE_HOST: "127.0.0.1"
      RAILS_ENV: test
    working_directory: ~/minoirominori
    steps:
      - checkout:
          path: ~/minoirominori
      - ruby/install-deps
      - run:
          name: Database setup
          command: bundle exec rails db:migrate
      - run:
          name: rspec
          command: |
            bundle exec rspec --format RspecJunitFormatter \
                              --out test_results/rspec.xml \
                              --format documentation
      - run:
          name: Rubocop
          command: bundle exec rubocop


  deploy:
    docker:
      - image: circleci/ruby:3.0.2
    steps:
      - checkout
      - setup_remote_docker:
          version: 20.10.6
      - heroku/install
      - run:
          name: heroku login #こちらでエラー発生
          command: heroku container:login
      - run:
          name: push docker image
          command: heroku container:push web -a $HEROKU_APP_NAME
      - run:
          name: release docker image
          command: heroku container:release web -a $HEROKU_APP_NAME
      - run:
          name: database setup
          command: heroku run bundle exec rake db:migrate RAILS_ENV=production -a $HEROKU_APP_NAME

workflows:
  version: 2
  build_test_and_deploy:
    jobs:
      - build
      - test:
          requires:
            - build
      - deploy:
          requires:
            - test
          filters:
            branches:
              only: main

エラー内容

Error response from daemon: login attempt to https://registry.heroku.com/v2/ failed with status: 401 Unauthorized
 ▸    Login failed with: 1


Exited with code exit status 1
CircleCI received exit code 1

DockerからHerokuにログインできませんとのこと。401 Unauthorizedとは認証がきちんとできていませんという意味みたいです。エラー通りhttps://registry.heroku.com/v2/ こちらのサイトにアクセスするとユーザー名とパスワードを入れる欄が出てきます。
何度もユーザー名にherokuの自分のアドレス、パスワードにherokuのパスワードを入れるもログインできず、、
複数の記事を参照し解決策が判りました!

解決策

ユーザー名は空のまま
パスワードには、cdで該当する自分のディレクトリに移動した後heroku auth:tokenで発行した数字を入れることで解決しました!

参考

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?