Im trying to push a docker image to public docker repository using github actions following their documentation but I cant make it work:
name: CI
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/docker/login@master
with: # Set the secret as an input
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
env: # Set the secret in the env
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Test
run: mvn clean verify -U
- name: build
run: ./mvnw compile jib:dockerBuild
- name: push
run: docker push odfsoft/guess-game:latest
I get the following error:
/usr/bin/docker run --name bb8146f4246c56a44203bb2667ccfbdcab81_f18969 --label 04bb81 --workdir /github/workspace --rm -e DOCKER_USERNAME -e DOCKER_PASSWORD -e INPUT_DOCKER_USERNAME -e INPUT_DOCKER_PASSWORD -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/spring-boot-guess-game/spring-boot-guess-game":"/github/workspace" 04bb81:46f4246c56a44203bb2667ccfbdcab81
Error: Cannot perform an interactive login from a non TTY device
is this something related to my action or a limitation in github actions?
You can store and manage Docker and OCI images in the Container registry, which uses the package namespace https://ghcr.io . GitHub Packages is available with GitHub Free, GitHub Pro, GitHub Free for organizations, GitHub Team, GitHub Enterprise Cloud, GitHub Enterprise Server 3.0 or higher, and GitHub AE.
Docker has become an industry standard in providing run-time environments to cloud services. This lesson shows how you can use Docker images inside Github Actions. Our specific example will show a neat way to build a simple website that goes with any project you might have going.
The actions/docker action has now been deprecated. If you visit the repository you will see that the repository is archived and has the following message.
This action is deprecated in favor of using the run script step in the new YAML language to run the docker cli.
https://github.com/actions/docker
So the recommended way to login to Docker registries is to use the run script command as follows.
For the public DockerHub registry:
name: my workflow
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Login to DockerHub Registry
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
For a private registry, such as the new GitHub Package Registry, you also need to specify the hostname:
name: my workflow
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Login to GitHub Package Registry
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login docker.pkg.github.com -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
Also see this answer for complete workflow examples of docker image publishing.
I found Git hub action: Build and push Docker images
https://github.com/marketplace/actions/build-and-push-docker-images
It works well, I was able to build and push docker image to Docker Hub.
https://github.com/marketplace/actions/docker-login
Try this action instead as actions/docker/login@master appears to have been deprecated.
I found Git hub action: Build and push Docker images
https://github.com/marketplace/actions/build-and-push-docker-images
It works well, I was able to build and push docker image to Docker Hub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With