Home > front end >  What is the reason for "docker: Error response from daemon: No command specified."?
What is the reason for "docker: Error response from daemon: No command specified."?

Time:02-05

Starting from my last commit yesterday I am encountering with a strange problem where GitLab CI fails continuously with an error as shown below:

$ ssh -i $SSH_PRIVATE_KEY -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker run -d -p 8010:80 --name my_project $TAG_LATEST"
docker: Error response from daemon: No command specified.
See 'docker run --help'.
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 125

This is an React App which should be build and deployed to my server.

This is my Dockerfile

FROM node:16.14.0-alpine as build

WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM nginx:1.19-alpine

COPY --from=build /app/build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/conf.d
EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]

In .gitlab-ci.yml file I have 2 stages build and deploy. For more clarity I would like to share it eaither:

stages:
  - build
  - deploy

variables:
  TAG_LATEST: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: "/certs"

build_test:
  image: docker:latest
  stage: build
  services:
    - docker:19.03.0-dind
  script:
    - docker build -t $TAG_LATEST .
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
    - docker push $TAG_LATEST
  environment:
    name: test
  rules:
    - if: $CI_COMMIT_BRANCH == "develop"
      when: on_success


deploy_test:
  image: alpine:latest
  stage: deploy
  only:
    - develop
  tags:
    - frontend
  script:
    - chmod og= $SSH_PRIVATE_KEY
    - apk update && apk add openssh-client
    - ssh -i $SSH_PRIVATE_KEY -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY"
    - ssh -i $SSH_PRIVATE_KEY -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker pull $TAG_LATEST"
    - ssh -i $SSH_PRIVATE_KEY -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker container rm -f my_project || true"
    - ssh -i $SSH_PRIVATE_KEY -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker run -d -p 8010:80 --name my_project $TAG_LATEST"
  environment:
    name: test

I did the following steps:

1st tried to run image using docker run command manually in my server. The result was the same!

2nd I pulled project from gitlab to the brand new folder and run first docker build -my_project . command then as I did it in server. It worked on my local machine.

3rd I re-verified my code base with ChatGPT and it found no error.

CodePudding user response:

I got the same error since 3 days. I also use gitLab CI.

I solved the issue by adding this line in my docker-compose.yml file (in the involved service section)

command: ["nginx", "-g", "daemon off;"]

I not yet find the root cause of the issue.

Hope that will help.

CodePudding user response:

Currently there's an issue with latest docker release.

Use:

image: docker:20.10.22

instead of :

image: docker:latest

For more details check this link: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/29593#note_1263383415

  • Related