I am trying to run the following docker-compose yml in the github workflow, but I get the error of
Error response from daemon: No such image: ghcr.io/whats/app/backend/222243434353535353f
The error happens at the "Tag images" point below
The docker Ci file is
env:
WEB_IMAGE_BASE: ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')/backend
WEB_IMAGE: ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')/backend:$( echo $GITHUB_SHA )
jobs:
build:
name: Build Docker Images
runs-on: ubuntu-latest
steps:
- name: Prepare images
run: |
echo "WEB_IMAGE=$(echo ${{env.WEB_IMAGE}} )" >> $GITHUB_ENV
echo "WEB_IMAGE_BASE=$(echo ${{env.WEB_IMAGE_BASE}} )" >> $GITHUB_ENV
- name: Build images
run: |
docker-compose -f ci.yml build backend
- name: Tag images
run: |
docker tag ${{ env.WEB_IMAGE }} ${{ env.WEB_IMAGE_BASE }}:latest
The ci.yml is
version: "3.9"
services:
backend:
image: backend_prod
What am I doing wrong or please indicate how to fix this?
CodePudding user response:
You are trying to tag and image using as a source an image that doesn't exist.
The image ghcr.io/whats/app/backend/222243434353535353f
wasn't created in any place.
You need to use as a source in tag command the built image result of docker-compose build.
Since you specify in your compose the image: backend_prod
your image will be named by that.
Try to change the image in your docker compose to something like:
version: "3.9"
services:
backend:
build:
context: .
dockerfile: ./backend/dockerfile
image: backend_prod:local
And change your ci file:
- name: Tag images
run: |
docker tag backend_prod:local ${{ env.WEB_IMAGE_BASE }}:latest
You can read more about the image tag in docker-compose here