Today I have deployed my website via digitalOcean with docker file, but I got an issue that I cant view my website (link: http://18.104.22.168:4000)
I checked my website on my local, it works fine
exp: when I type “docker run -d -p 4000:3000 ductrung/test-ci-cd:v1”, I can view my website from port 4000
I just checked log on my server and I saw my container when my web deployed it had status running, but when user go to the page container will exit and response “This site can’t be reached”,
Hope guys can help me, Thank you
# ==== CONFIGURE ===== # Use a Node 16 base image FROM node:16-alpine # Set the working directory to /app inside the container WORKDIR /app # Copy app files COPY . . # ==== BUILD ===== # Install dependencies (npm ci makes sure the exact versions in the lockfile gets installed) RUN npm ci # Build the app RUN npm run build # ==== RUN ======= # Set the env to "production" ENV NODE_ENV production # Expose the port on which the app will be running (3000 is the default that `serve` uses) EXPOSE 3000 # Start the app CMD [ "npx", "serve", "build" ]
variables: IMAGE_NAME: ductrung/test-ci-cd IMAGE_TAG: v1 services: - docker:dind stages: - test - build - deploy run-tests: image: cypress/browsers:node18.12.0-chrome107 stage: test script: - echo Pass test .build: stage: build image: docker:20.10.16 services: - docker:20.10.16-dind variables: DOCKER_TLS_CERTDIR: "" before_script: - echo Welcome to come new world, $USER_NAME - echo $IMAGE_NAME:$IMAGE_TAG - docker login -u $REGISTRY_USER -p $REGISTRY_PASSWORD script: - docker build -t $IMAGE_NAME:$IMAGE_TAG . - docker push $IMAGE_NAME:$IMAGE_TAG build-dev: extends: .build only: - main deploy_development: stage: deploy before_script: - chmod 400 $SSH_KEY script: - echo $SSH_KEY $HOST - ssh -o StrictHostKeyChecking=no -i $SSH_KEY firstname.lastname@example.org " docker login -u $REGISTRY_USER -p $REGISTRY_PASSWORD && docker run -d -p 4000:3000 $IMAGE_NAME:$IMAGE_TAG"
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $200 of credit to try our products over 60 days!
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
As per Bobby’s suggestion, this seems to be related to the Firewall configuration of your droplet.
If you’re running
ufwor any other firewall management tool you can check that the port is open and accepting requests.
As you are getting connection refused when trying to visit that port, do you by any chance have a firewall on your Droplet?
If this is the case you need to open that port in order to be able to access it. For example if you are using
ufw, then you need to run:
ufw allow 4000.
Let me know how it goes!