Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Docker-compose doesn't work #274

Open
mirkoperillo opened this issue Oct 22, 2022 · 2 comments
Open

Docker-compose doesn't work #274

mirkoperillo opened this issue Oct 22, 2022 · 2 comments

Comments

@mirkoperillo
Copy link
Contributor

  • Version: 0.62.3
  • Platform: Ubuntu 20.04
  • Docker Version: 20.10.19
  • Docker-compose Version: 1.29.1

docker-compose doesn't work out of the box.

Running the command sudo docker-compose -f dockerfiles/docker-compose.yml up the jackal service fails to start with this log message

jackal_1  | exec ./wait-for-it.sh: exec format error
@mirkoperillo
Copy link
Contributor Author

I have tried to understand better the problem, more details about:

  • If I try to change command in docker-compose.yml to run a simple command like echo:
command:
     - echo
     - "Hi Jackal!"

I've got the same error exec format error

  • If I try to run directly jackal output is ok
command:
     - ./jackal

The problem seems specific of the jackal docker image. I've tried to run wait-for-it using directly the debian:stable-slim image (the one used by jackal image) and wait-for-it script works correctly

jackal:
    image: debian:stable-slim
    depends_on:
      - etcd
      - pgsql
    volumes:
      - ../scripts:/scripts
    command:
      - /scripts/wait-for-it.sh
      - pgsql:5432
      - --
      - echo
      - "Hi Jackal!"

Output

jackal_1  | wait-for-it.sh: waiting 15 seconds for pgsql:5432
jackal_1  | wait-for-it.sh: pgsql:5432 is available after 0 seconds
jackal_1  | Hi Jackal!
dockerfiles_jackal_1 exited with code 0

@mirkoperillo
Copy link
Contributor Author

mirkoperillo commented Oct 28, 2022

More tests about the problem.

I think I have isolated the problem, it is something about the image platform used by docker-compose.

To test this I have created a Dockerfile.local without --platform=$BUILDPLATFORM and GOARCH=$TARGETARCH part, so something like this

FROM golang:1.19.1-bullseye as stage

ADD . /src
WORKDIR /src

RUN CGO_ENABLED=0 GOOS=linux go build -a -tags netgo -ldflags "-s -w" "github.com/ortuman/jackal/cmd/jackal"
RUN CGO_ENABLED=0 GOOS=linux go build -a -tags netgo -ldflags "-s -w" "github.com/ortuman/jackal/cmd/jackalctl"
RUN chmod +x jackal jackalctl

FROM debian:stable-slim

RUN apt-get update && apt-get install -y ca-certificates
RUN update-ca-certificates

WORKDIR /jackal

COPY --from=stage /src/jackal /jackal
COPY --from=stage /src/jackalctl /jackal

EXPOSE 5222

ENV PATH $PATH:/jackal

CMD ["./jackal"]

and have used this Dockerfile.local directly into docker-compose, so with a jackal service definition like this

 jackal:
    build:
      context: ..
      dockerfile: dockerfiles/Dockerfile.local
    ports:
      - 5222:5222
      - 15280:15280
    environment:
      - JACKAL_LOG_STANZAS=on
    depends_on:
      - etcd
      - pgsql
    working_dir: /jackal
    volumes:
      - ../scripts/wait-for-it.sh:/jackal/wait-for-it.sh
      - ../config/docker-compose.config.yaml:/jackal/config.yaml
    command:
      - ./wait-for-it.sh
      - pgsql:5432
      - --
      - ./wait-for-it.sh
      - etcd:2379
      - --
      - ./jackal

then I have executed the command
sudo docker-compose -f dockerfiles/docker-compose.yml up --force-recreate

and wait-for-it.sh script works as expected

The output:

jackal_1  | wait-for-it.sh: waiting 15 seconds for pgsql:5432
jackal_1  | wait-for-it.sh: pgsql:5432 is available after 0 seconds
jackal_1  | wait-for-it.sh: waiting 15 seconds for etcd:2379
jackal_1  | wait-for-it.sh: etcd:2379 is available after 0 seconds
jackal_1  | level=info ts=2022-10-28T16:55:13.685507956Z caller=jackal.go:190 msg="jackal is starting...
...
...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant