0

I created a simple VueJS app with a very basic configuration. I used the webpack configuration to do this.

vue init webpack app

I build this simple Dockerfile

FROM node:lts-alpine

# install simple http server for serving static content
RUN npm install -g http-server

# make the 'app' folder the current working directory
WORKDIR /app

# copy both 'package.json' and 'package-lock.json' (if available)
COPY package*.json ./

# install project dependencies
RUN npm install

# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY . .

# build app for production with minification
RUN npm run build

EXPOSE 3838
CMD [ "http-server", "dist" ]

This app should run of a plattform which only listens to port 3838. Changing the Dockerfile to EXPOSE 3838 did not work unfortunately.

sudo docker run -it -p 3838:3838 vuetest

Starting up http-server, serving dist
Available on:
  http://127.0.0.1:8080

The container runs, but stil on 8080.

I´m quite unfamiliar with both VueJS and deploying, so can anyone help me? I guess the configuration to listen to 8080 might be set in a different file and the Dockerfile ignores it.

2 Answers 2

5

Your application server runs by default on 8080

https://www.npmjs.com/package/http-server

Use flag -p 3838 to serve on that port. Docker is doing its job correctly, adjust in your CMD

CMD [ "http-server", "-p 3838", "dist" ]

Sign up to request clarification or add additional context in comments.

Comments

2

You can try just use the port 8080 of the continer and map it to port 3838 of your host.

#Dockerfile: delete the line -> Expose 3838
#Command line : $ sudo docker run -it -p 3838:8080 vuetest

This is an option not to add more lines to the Dockerfile. Bye

3 Comments

OP says platform only has port 3838 port open to put a service behind. At least that what i interpret from 'This app should run of a plattform which only listens to port 3838' ... could be wrong tho.
Hi. You're right to. If any answer solve his problem, it will be fine. I am sorry for my bad english. Greetings from Argentina
its cool, its hard enough to actually do these things, let alone discuss them via forum, even harder in a second or third language! Your answer also could solve a similar problem for others!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.