[Topic DIscussion] Docker container refused connection
Tofloor
poster avatar
a***[email protected]
deepin
2023-07-07 17:45
Author

Hello Everyone, I will open new thread "Docker container refused connection". Anyone who have experience will help me .

docker run --rm -hostname=wizdwarfs -p 127.0.0.1:5000:5000 -v /app/app_data --net=host -it wizdwarfs:0

Application started 😃

When I open my browser and type https://localhost:5000/ browser refused connection container already running

🙁

Reply Favorite View the author
All Replies
owen_337
deepin testing team
2023-07-07 18:23
#1

Hello! According to your description, when you enter https://localhost:5000/ When, the browser refused to connect to the running container. This may be due to one of the following reasons:

  1. The port mapping of the container is incorrect. Please ensure that the port mapping settings for the container are correct, mapping port 5000 of the container to port 5000 of the host. You can use the following command to run the container and set the correct port mapping:

docker run --rm -hostname=wizdwarfs -p 5000:5000 -v /app/app_data --net=host -it wizdwarfs:0

  1. The container's application did not properly listen to the host's port 5000. Please ensure that your application correctly listens to the host's port 5000 within the container. You can check the application's code or configuration files to ensure that it is listening to the correct port.
Reply View the author
a***[email protected]
deepin
2023-07-07 19:26
#2
owen_337

Hello! According to your description, when you enter https://localhost:5000/ When, the browser refused to connect to the running container. This may be due to one of the following reasons:

  1. The port mapping of the container is incorrect. Please ensure that the port mapping settings for the container are correct, mapping port 5000 of the container to port 5000 of the host. You can use the following command to run the container and set the correct port mapping:

docker run --rm -hostname=wizdwarfs -p 5000:5000 -v /app/app_data --net=host -it wizdwarfs:0

  1. The container's application did not properly listen to the host's port 5000. Please ensure that your application correctly listens to the host's port 5000 within the container. You can check the application's code or configuration files to ensure that it is listening to the correct port.

here is my dockerfile which is prefectly run in ubuntu .. however in deepin it may cause problematic

# This codebase desgin according to mozilla open source license.
# Redistribution , contribution and improve codebase under license
# convensions. @contact Ali Hassan [email protected]

# base image 
FROM golang:1.19beta1-alpine3.15

# environment params  
ENV CGO_ENABLED=0

ENV PORT=5000

ENV HOST=wizdwarfs


# app workspace

RUN mkdir /app

ADD . /app

WORKDIR /app

# set persist storage
ARG WIZ_DIR=/app_data

RUN mkdir -p ${WIZ_DIR}

# declaration persistance storage
ENV WIZ_VOLUME_DIR=/app${WIZ_DIR}/apps.txt

# app modules 
COPY go.mod go.sum ./

RUN go mod tidy

#RUN go mod vendor

RUN go mod download

# build app 
RUN go build -o wizdwarfs 

# testing
RUN go test ./...

# && go test -v ./... 

# publish app port
EXPOSE 5000

# peristance storage 
VOLUME [ ${WIZ_DIR} ]

# certs
RUN apk --no-cache add ca-certificates

LABEL designed="Wisdom-Enigma Inc"

# initialization container
CMD ["/app/wizdwarfs"]

Reply View the author