I've been trying to get Docker working with Postgres and Flask and I was having issues with Postgres password and docker not being able to find my entry.sh file. This seemed to be an issue with docker not updating properly, but now after updating, I am getting "go" errors when I run docker-compose up, and I don't know what they mean.
Here's the error log:
panic: runtime error: index out of range [1] with length 1
goroutine 37 [running]:
github.com/docker/compose-cli/pkg/compose.(*convergence).ensureService(0xc00027ff20, 0x2120ba8, 0xc000454450, 0xc000240f00, 0xc0001ce7c8, 0x3, 0x0, 0x0, 0x0, 0xc000240a00, ...)
github.com/docker/compose-cli/pkg/compose/convergence.go:222 +0x11f1
github.com/docker/compose-cli/pkg/compose.(*convergence).apply.func1(0x2120ba8, 0xc000454450, 0xc0001ce7c8, 0x3, 0x0, 0x0)
github.com/docker/compose-cli/pkg/compose/convergence.go:99 +0x21f
github.com/docker/compose-cli/pkg/compose.run.func1(0x0, 0x0)
github.com/docker/compose-cli/pkg/compose/dependencies.go:102 +0xa3
golang.org/x/sync/errgroup.(*Group).Go.func1(0xc000590540, 0xc000626180)
golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:57 +0x59
created by golang.org/x/sync/errgroup.(*Group).Go
golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:54 +0x66
Heres my docker-compose.yml:
services:
api:
container_name: api
build:
context: .
dockerfile: api/Dockerfile.api
image: mutcompute-api
ports:
- "5000:5000"
volumes:
- ./api:/app/
env_file:
- ./api/.env
command: gunicorn -b 0.0.0.0:5000 api:app && flask db upgrade
# entrypoint: ["./api/entry.sh"]
depends_on:
- db
client:
container_name: client
build:
context: .
dockerfile: client/Dockerfile.client
image: mutcompute-client
ports:
- "3000:3000"
volumes:
- ./client:/app/
email:
container_name: email
build:
context: .
dockerfile: api/Dockerfile.api
image: mutcompute-api
ports:
- "8025:8025"
command: python -m smtpd -n -c DebuggingServer 0.0.0.0:8025
db:
image: postgres:13-alpine
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_USER: mutcompute
POSTGRES_PASSWORD: mutcompute
POSTGRES_DB: mutcompute_dev
networks:
- default
ports:
- 5405:5432
restart: always
volumes:
- ./postgres-data:/var/lib/postgresql/data
My Dockerfile:
FROM python:slim
LABEL maintainer="Brad Alexander"
RUN useradd mutcompute
WORKDIR /app
COPY . /app/
COPY entry.sh /app/
ENV FLASK_APP api.py
RUN chown -R mutcompute:mutcompute /app && \
# chmod +x ./entry.sh && \
pip install -r requirements.txt
USER mutcompute
EXPOSE 5000
And a rough file tree
Project
|-api
|-app/
|-Dockerfile-api
|-entry.sh
|-client
|-src/
|-Dockerfile-client
|-Docker-compose.yml
The client is React, and was working fine before the update.
Sometimes when I edit the compose file, it starts to recreate the api container then fails like this:
⠙ Container api Recreate 0.2s
⠙ Container bb72362b9e19_api Recreate 0.2s
panic: runtime error: index out of range [1] with length 1
...
Hopefully this is enough information. I really appreciate any help!