I have simple vue.js app, here is my dockerfile:
FROM node:latest
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run generate
EXPOSE 3000
CMD ["npm", "run", "start"]
I run it using:
docker run -p 3000:3000 frontend-name:0.1
but it does not work then. if I will run it using --net=host it works fine.
the same issue if I try using docker-compose with port mapping.
what can be the issue ?
Related
After building I start the image and see in the terminal:
*Executing task: docker run --rm -it -p 3000:3000/tcp bamdock:latest
Listening on 0.0.0.0:3000*
However when trying to reach http://localhost:3000/ in browser I see:
*The connection was reset*
*The connection to the server was reset while the page was loading.
The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer’s network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the web.*
This is my Dockerfile:
FROM node:19 as builder
RUN npm install -g pnpm
WORKDIR /usr/src/app
COPY package*.json ./
RUN pnpm install
COPY prisma ./prisma/
COPY .env ./
RUN npx prisma generate
COPY . .
RUN pnpm run build
FROM node:19-alpine3.16
WORKDIR /app
COPY --from=builder /usr/src/app/build .
COPY --from=builder /usr/src/app/package.json .
COPY --from=builder /usr/src/app/node_modules ./node_modules
EXPOSE 3000
CMD ["node", "index.js"]
Any ideas what I'm missing?
My first time trying to get Docker working ...
I'm running Vue in a docker container. In my Dockerfile, I'm trying to run the command:
http-server dist --proxy http://localhost:8080?"
Here's my Dockerfile:
FROM node:lts-alpine
RUN npm install -g http-server
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
EXPOSE 8080
CMD [ "http-server", "dist", "--proxy http://localhost:8080?"]
I have tried placing "--proxy http://localhost:8080?" everywhere in the CMD array.
"http-server --proxy http://localhost:8080?"
results in an error.
Any direction on how to get the --proxy option to run?
Thanks,
It's probably expecting --proxy http://localhost:8080 to be two separate parameters. It's what Bash does when parsing the same command.
CMD [ "http-server", "dist", "--proxy", "http://localhost:8080?"]
OK, I ran out of ideas now. I am trying to get nodemon to work in a dockerized (Docker Toolbox, Win 8.1) simple nodejs app.
file structure
Dockerfile
FROM node:latest
USER root
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
RUN npm install -g nodemon
COPY . .
EXPOSE 3000
CMD [ "npm", "run", "devStart" ]
script
"devStart": "nodemon --ext ejs,js,json,css --watch server --watch views server/server.js",
-it output
Everything seems to match, but when I edit a partial/view nodemon does not restart.
Tried with nodemon as production (ie. not dev) dependency and then npx nodemon... - wouldn't work either.
I am new to docker.
I have created a Dockerfile which runs an Angular application inside nginx+docker.
### STAGE 1: Build ###
FROM node:12.7-alpine AS build
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build
### STAGE 2: Run ###
FROM nginx:1.17.1-alpine
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=build /usr/src/app/dist/jenkins-test /usr/share/nginx/html
to run this i do docker build -t my-app-multistage-image . and after that to run container I do docker run --name my-app-multistage-container -d -p 8888:80 my-app-multistage-image
It is working fine, now I want to use docker-compose to build and run the container, but no idea how to do that, can anyone please help me.
One code i tried which is obviously not working is
version: '3'
services:
web:
build: .
ports:
- "8888:80"
Thanks
I have an Angular - Flask app that I'm trying to dockerize with the following Dockerfile:
FROM node:latest as node
COPY . /APP
COPY package.json /APP/package.json
WORKDIR /APP
RUN npm install
RUN npm install -g #angular/cli#7.3.9
CMD ng build --base-href /static/
FROM python:3.6
WORKDIR /root/
COPY --from=0 /APP/ .
RUN pip install -r requirements.txt
EXPOSE 5000
ENTRYPOINT ["python"]
CMD ["app.py"]
On building the image and running the image, console gives no errors. However, it seems to be stuck. What could be the issue here?
Is it because they are both in different directories?
Since I'm dockerizing Flask as well as Angular, how can I put both in same directory (right now one is in /APP and the other in /root)
OR should I put the two in separate containers and use a docker-compose.yml file?
In that case, how do I write the file? Actually my Flask calls my Angular and both run on same port. So I'm not sure if running in two different containers is a good idea.
I am also providing the commands that I use to build and run the image for reference:
docker image build -t prj .
docker container run --publish 5000:5000 --name prj prj
In the Angular build first stage of the Dockerfile, use RUN instead of CMD.
CMD is for running a command after the final image is built.