Docker-compose创建的容器无法看到入口点。

huangapple go评论44阅读模式
英文:

The container created by docker-compose does not see the entrypoint

问题

I encountered a problem in docker-compose that the api service doesn't see the entrypoint.sh and crashes. Specific error:
> exec /app/entrypoint.sh: no such file or directory

Dockerfile:

FROM ruby:3.1.0-slim

ENV LANG=C.UTF-8
WORKDIR app
RUN apt-get update && apt-get -y install build-essential libpq-dev autoconf autogen libtool
EXPOSE 3000

COPY Gemfile /app/Gemfile
COPY Gemfile.lock /app/Gemfile.lock

RUN bundle install

COPY ./entrypoint.sh .

ENTRYPOINT ["/app/entrypoint.sh"]

.docker-compose.yml:

services:
  es:
    image: elasticsearch:8.7.0
    environment:
      - discovery.type=single-node
      - ES_JAVA_OPTS=-Xms750m -Xmx750m
      - xpack.security.enabled=false

  db:
    image: postgres:14.0-alpine
    environment:
      - POSTGRES_PASSWORD= ...
    ports:
      - 5431:5432

  redis:
    image: redis:7.0.11-alpine

  api:
    build: .
    volumes:
      - .:/app
    ports:
      - 3000:3000
    environment:
      - ELASTICSEARCH_URL=http://es:9200
      - REDIS_URL=redis://redis:6379
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    depends_on:
      - db
      - redis

The file structure of the container created for the api service:
Docker-compose创建的容器无法看到入口点。

Also, strangely enough, the dockerfile has not changed since it was successfully started. I can't figure out where the problem is. Help me, please Docker-compose创建的容器无法看到入口点。

I tried deleting all images, all containers, and all volumes, none of this helped.

英文:

I encountered a problem in docker-compose that the api service doesn't see the entrypoint.sh and crashes. Specific error:
> exec /app/entrypoint.sh: no such file or directory

Dockerfile:

FROM ruby:3.1.0-slim

ENV LANG=C.UTF-8
WORKDIR app
RUN apt-get update && apt-get -y install build-essential libpq-dev autoconf autogen libtool
EXPOSE 3000

COPY Gemfile /app/Gemfile
COPY Gemfile.lock /app/Gemfile.lock

RUN bundle install

COPY ./entrypoint.sh .

ENTRYPOINT ["/app/entrypoint.sh"]

.docker-compose.yml:

services:
  es:
    image: elasticsearch:8.7.0
    environment:
      - discovery.type=single-node
      - ES_JAVA_OPTS=-Xms750m -Xmx750m
      - xpack.security.enabled=false

  db:
    image: postgres:14.0-alpine
    environment:
      - POSTGRES_PASSWORD= ...
    ports:
      - 5431:5432

  redis:
    image: redis:7.0.11-alpine

  api:
    build: .
    volumes:
      - .:/app
    ports:
      - 3000:3000
    environment:
      - ELASTICSEARCH_URL=http://es:9200
      - REDIS_URL=redis://redis:6379
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    depends_on:
      - db
      - redis

The file structure of the container created for the api service:
Docker-compose创建的容器无法看到入口点。

Also, strangely enough, the dockerfile has not changed since it was successfully started. I can't figure out where the problem is. Help me, please Docker-compose创建的容器无法看到入口点。

I tried deleting all images, all containers and all volumes, none of this helped.

答案1

得分: 1

The executable in shebang of entrypoint.sh is not found inside docker container. Install the executable or change shabang. Most probably you have bash and bash is not inside the container, for example.

英文:

The executable in shebang of entrypoint.sh is not found inside docker container. Install the executable or change shabang. Most probably you have bash and bash is not inside the container, for exmaple.

huangapple
  • 本文由 发表于 2023年5月13日 16:58:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76241895.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定