I’m trying to run a vanilla js vite project in docker:
docker-compose.yml
version: '3'
services:
app:
build: .
ports:
- "5173:5173"
volumes:
- .:/usr/src/app
command: npm run dev
Dockerfile
# Use the official lightweight Node.js 14 image.
# https://hub.docker.com/_/node
FROM node:19
# Create and change to the app directory.
WORKDIR /usr/src/app
# Copy application dependency manifests to the container image.
# A wildcard is used to ensure both package.json AND package-lock.json are copied.
# Copying this separately prevents re-running npm install on every code change.
COPY package*.json ./
# Install vite globally in the Docker container.
RUN npm install
# Install all dependencies.
RUN npm install -g vite
# Copy local code to the container image.
COPY . .
docker-compose up --build
Creating network "vite-docker_default" with the default driver
Building app
[+] Building 4.9s (11/11) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 622B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:19 0.7s
=> [internal] load build context 0.0s
=> => transferring context: 1.29kB 0.0s
=> [1/6] FROM docker.io/library/node:19@sha256:92f06fc13bcc09f1ddc51f6ebf 0.0s
=> CACHED [2/6] WORKDIR /usr/src/app 0.0s
=> CACHED [3/6] COPY package*.json ./ 0.0s
=> [4/6] RUN npm install 3.0s
=> [5/6] RUN npm install -g vite 1.0s
=> [6/6] COPY . . 0.0s
=> exporting to image 0.1s
=> => exporting layers 0.1s
=> => writing image sha256:916da68b6a643e1d85ea3625a71b5c2c49ca528b90f6d8 0.0s
=> => naming to docker.io/library/vite-docker_app 0.0s
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Creating vite-docker_app_1 ... done
Attaching to vite-docker_app_1
app_1 |
app_1 | > [email protected] dev
app_1 | > vite
app_1 |
app_1 |
app_1 | VITE v5.2.10 ready in 130 ms
app_1 |
app_1 | ➜ Local: http://localhost:5173/
app_1 | ➜ Network: use --host to expose
When I open http://localhost:5173/
in the browser I get:
There are no logs in the container