build-push-action icon indicating copy to clipboard operation
build-push-action copied to clipboard

Docker: Cannot create container for service: No command specified

Open VivekPNs opened this issue 1 year ago • 1 comments

Contributing guidelines

I've found a bug, and:

  • [X] The documentation does not mention anything about my problem
  • [X] There are no open or closed issues that are related to my problem

Description

I'm trying to deploy my Node application to a different environment and as part of the process, I have set up a GitHub Actions workflow which has 2 jobs namely, build and deploy_dev. build job will build the image and upload it as an artifact and the deploy_dev job will download the artifact, tag it, and push it to ECR.

I did not encounter any error while building or tagging but, while running the pulled image within ECR, I'm getting the below error, so I'm not sure if it's due to a corrupted image or an issue with the way I'm building or tagging.

Error: Recreating ce3fc36b598e_my-service ... error for test-service Cannot create container for service test-service: No command specified

Here is my Dockerfile:

FROM node:10.16.0
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH

COPY package.json /usr/src/app/package.json
COPY package-lock.json /usr/src/app/package-lock.json
COPY app.js /usr/src/app

ADD src /usr/src/app/src
ADD tests /usr/src/app/tests
ADD migrations /usr/src/app/migrations

COPY .eslintrc.js /usr/src/app
COPY .prettierrc.js /usr/src/app
COPY migrate-mongo-config.js /usr/src/app/migrate-mongo-config.js

COPY .env.example /usr/src/app/.env

RUN npm install
RUN npm run lint

EXPOSE 5000
CMD ["npm", "start"]

I'm not sure about the mistake or if there is an issue while dealing with tar files for tagging and pushing.

Expected behaviour

Once the tar image file is downloaded and tagged properly without any error, it should be able to be pulled in to any ec2 machine and run it.

Actual behaviour

Error: Recreating ce3fc36b598e_my-service ... error for test-service Cannot create container for service test-service: No command specified

Repository URL

No response

Workflow run URL

No response

YAML workflow

name: my-service
'on':
  push:
    branches:
      - master
  workflow_dispatch: null
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Cache Docker layers
        uses: actions/cache@v2
        with:
          path: /tmp/.buildx-cache
          key: '${{ runner.os }}-buildx-${{ github.sha }}'
          restore-keys: |
            ${{ runner.os }}-buildx-
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Build docker image
        uses: docker/build-push-action@v4
        with:
          platforms: linux/amd64
          provenance: false
          cache-from: 'type=local,src=/tmp/.buildx-cache'
          cache-to: 'type=local,dest=/tmp/.buildx-cache'
          outputs: 'type=docker,dest=/tmp/my-service.tar'
      - name: Upload artifact
        uses: actions/upload-artifact@v3
        with:
          name: my-service
          path: /tmp/my-service.tar
  deploy_dev:
    needs: build
    runs-on: ubuntu-latest
    environment:
      name: dev
    steps:
      - name: Download artifact
        uses: actions/download-artifact@v3
        with:
          name: my-service
          path: /tmp
      - name: Configure aws credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: '${{ secrets.AWS_ACCESS_KEY_ID }}'
          aws-secret-access-key: '${{ secrets.AWS_SECRET_ACCESS_KEY }}'
          aws-region: us-east-1
      - name: Amazon ECR "Login" Action for GitHub Actions
        id: login-ecr
        uses: aws-actions/amazon-ecr-login@v1
        with:
          registry-type: private
          skip-logout: false
          mask-password: true
      - name: Deploy to dev
        env:
          ECR_REGISTRY: '${{ steps.login-ecr.outputs.registry }}'
        run: >
          docker image import /tmp/my-service.tar ${{ env.ECR_REGISTRY
          }}/my-service:dev

          docker push ${{ env.ECR_REGISTRY }}/my-service:dev

Workflow logs

No response

BuildKit logs

No response

Additional info

No response

VivekPNs avatar Jan 11 '24 03:01 VivekPNs

Error: Recreating ce3fc36b598e_my-service ... error for test-service Cannot create container for service test-service: No command specified

These logs are not enough. Please post link to your repo if possible that woudl be easy to find out the issue or open a public one with minimal repro. Or full workflow logs in worst case. Thanks.

crazy-max avatar Jan 17 '24 10:01 crazy-max