Cannot push docker image into docker hub from Github Action

Hi All,

I have yaml file in GitHub action and i have successfully build docker image in it and i want to push into docker hub but getting below error

Run docker push ***/vampi_docker:latest
docker push ***/vampi_docker:latest
shell: /usr/bin/bash -e {0}
An image does not exist locally with the tag: ***/vampi_docker
The push refers to repository [docker.io/***/vampi_docker]
Error: Process completed with exit code 1.

Here is the yml file

name: vampi_docker
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: docker login
      env:
        DOCKER_USER: ${{secrets.DOCKER_USER}}
        DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
        repository: rashidmd/vampi_docker:latest
        tags: latest, ${{ secrets.DOCKER_TOKEN }}
      run: |
        docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
        
    - name: Build the Vampi Docker image
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
        docker build . --file Dockerfile --tag vampi_docker:latest
        
    - name: List images
      run: docker images    
    - name: Docker Push
      run: docker push ${{secrets.DOCKER_USER}}/vampi_docker:latest

Please do let me know where im wrong and what i miss

You need to tag the newly built image with the full Docker Hub name before pushing, e.g.:

docker tag vampi_docker:latest ${{secrets.DOCKER_USER}}/vampi_docker:latest

i have added like this

 name: Docker Push
     # run: docker push ${{secrets.DOCKER_USER}}/vampi_docker:latest
        run: docker tag vampi_docker:latest ${{secrets.DOCKER_USER}}/vampi_docker:latest

Job executed successfully but image doesn’t push into docker hub …i check docker hub it showing empty

You need to do both. Tag first, then push.

problem solve but i want to deploy container using that image in github action can u tell me how to do it …any links or steps will be great for me in doing

What exactly you want to do and achieve?

i want to run that image as a docker container in github action …i already have deploy image in github action now want to run that image as container …thats my task

If you just want to run the container, you can do a docker run command as you would locally.

If you want to keep the container running after the Actions workflow completes you need to do that elsewhere (e.g. with a hoster), how to start it there from Actions depends on where the “elsewhere” is.

Yes, i want my container to be running please give us any link or website or any command to do it…hoster i didnt understand it …if u r saying about VM deploy that also i can do it…just need commands or website

Consider using an action to build and push the image. It will be less error prone, it handles the login and any other post actions (logout). I find it easier to maitain:

- name: build image
  id: build-image
  uses: redhat-actions/buildah-build@v2
  with:
    image: myuser/myimage
    tags: latest
    dockerfiles: |
      ./Dockerfile

- name: push image to ghcr.io
  uses: redhat-actions/push-to-registry@v2
  with:
    image: ${{ steps.build-image.outputs.image }}
    tags: ${{ steps.build-image.outputs.tags }}
    registry: ghcr.io
    username: ${{ github.actor }}
    password: ${{ secrets.GITHUB_TOKEN }}