I am trying to wrap my golang worker app into docker image. I have successfully build image. But when I run, it turns out that my docker container cannot connect to my faktory. Here is my docker file:
# builder image
FROM golang:1.14.11-alpine AS builder
# specific directory for build process
WORKDIR /usr/src/build
# copying the source code
# to the current working directory
COPY . .
RUN apk add --no-cache git
ENV GOPRIVATE=gitlab.com/pinvest/backends/backend-structs
# RUN echo "machine gitlab.com login jais_pinhome password pinhome123" > ~/.netrc
COPY .netrc /root/.netrc
# executing build process
RUN GOOS=linux go build -ldflags="-s -w" -o app
# runtime image
FROM golang:1.14.11-alpine AS runtime
# create and use non-root user
# to increase container security
# ref https://pythonspeed.com/articles/root-capabilities-docker-security/
RUN adduser myuser --disabled-password
USER myuser
WORKDIR /home/myuser
# copy the executable binary file from builder directory
# to the current working directory
COPY --from=builder /usr/src/build/app .
# exposing port
EXPOSE 8080
# run the application
CMD ["./app"]
and here is the log my faktory:
jaisanas@DESKTOP-H2GJLP8:~/work/worker$ faktory
Faktory 1.4.0
Copyright ? 2021 Contributed Systems LLC
Licensed under the GNU Public License 3.0
I 2021-01-23T01:52:15.239Z Initializing redis storage at /home/jaisanas/.faktory/db, socket /home/jaisanas/.faktory/db/redis.sock
I 2021-01-23T01:52:15.251Z Web server now listening at localhost:7420
I 2021-01-23T01:52:15.251Z PID 6897 listening at localhost:7419, press Ctrl-C to stop
If I run the worker container returns error like below:
jaisanas@DESKTOP-H2GJLP8:~/work/worker$ docker run --env-file docker_env.sh -p 8080:27017 --name woker worker
2021/01/23 01:48:40.502243 [0 <nil>] unsupported protocol scheme ""
2021/01/23 01:48:40.502380 faktory_worker_go PID 1 now ready to process jobs
2021/01/23 01:48:40.681601 dial tcp 127.0.0.1:7419: connect: connection refused
2021/01/23 01:48:40.704490 dial tcp 127.0.0.1:7419: connect: connection refused
2021/01/23 01:48:40.711848 dial tcp 127.0.0.1:7419: connect: connection refused
2021/01/23 01:48:40.845921 dial tcp 127.0.0.1:7419: connect: connection refused
2021/01/23 01:48:40.876556 dial tcp 127.0.0.1:7419: connect: connection refused
Is anyone here familiar with wrapping up golang faktory app into docker and facing the similar issue?
question from:
https://stackoverflow.com/questions/65878947/dockerize-app-cannot-connect-to-faktory-worker 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…