Here is the Docker file
After this part, it says an error.
Related
I'm running a docker container with PHP and node installed through nvm. A Symfony 6 app is mounted into it.
I'd like to user Symfony 6's "Encore" tool to compile my assets.
I connect to my container like this:
sudo docker exec -ti 860cb4e01268 bash
And then I move to the directory when my symfony app is mounted.
Typing npm run build returns the following message /usr/bin/env: 'node': Permission denied
Node is installed and $PATH seems correct, when I type node, I can enter the node console as expected. Same thing if I type /usr/bin/env: node.
Still from inside the container, a whoami returns "root", so I don't get how I could have a permission issue.
Finally, if I directly run node node_modules/#symfony/webpack-encore/bin/encore.js prod, it works and builds my asset as expected.
I don't get why a simple npm run build won't work?
Instead of installing node through nvm, I installed it like suggested here https://askubuntu.com/questions/720784/how-to-install-latest-node-inside-a-docker-container. A npm run build now works as expected.
I finally updated my docker-compose.yml file like this:
nodejs:
image: node:16.16.0
working_dir: /website
command: npm run watch
volumes:
- /home/path-to-my-website-files-on-host-machine:/website
ports:
- 8888:8888
This way, each time I edit something in a js or css file, everything gets automatically rebuild and minified by Symfony Encore/Webpack
im new with docker i installed the latest docker for windows
but when run linux container on docker windows and i try to open http://localhost:5104/ in the browser i just get an empty response. Chrome: ERR_EMPTY_RESPONSE
Background
So I'm trying to set up a Docker container for development, and one of my dependencies is webpack.
Repo Steps:
install this in the image with an npm install webpack.
The image builds successfully
I run it
In the Docker Desktop GUI shell I type webpack -v
Then get output webpack: command not found.
Question
How does it not find the command if it was one of the dependencies installed on the base image?
I am working on a desktop application build using ElectronJS framework on Windows.
May be I haven't understood Docker properly, but how do I use docker for this app?
My end goal is to not let people install node, npm and electron packages on their local system. They can use the docker image to develop this application.
Update
I figured out how to package my project in docker image. Now I am struggling to run the app through the Docker Container.
How to run a GUI(Electron Application) application using docker container?
Thanks.
In your case you need custom docker images that will have node, npm and ElectronJS in it.
I found one such image on dockerhub, you can use it or build your own custom image by checking its dockerfile.
I have a React app that I would like to Dockerize for Windows containers. this my Dockerfile:
FROM stefanscherer/node-windows
# Override the base log level (info).
ENV NPM_CONFIG_LOGLEVEL warn
# Expose port for service
EXPOSE 80
# Install and configure `serve`.
RUN npm install -g serve
# Copy source code to image
COPY . .
# Install dependencies
RUN npm install
# Build app and start server from script
CMD [ "npm", "start" ]
The image is successfully built, but when I try to run it I get this error:
Error response from daemon: container 3b4b9e2bab346bbd95b9dc144429026c1abbe7f4d088f1f10d4c959364f50e9e encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {"CommandLine":"npm start","WorkingDirectory":"C:\\","Environment":{"NPM_CONFIG_LOGLEVEL":"warn"},"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}.
I am new with Docker so I not sure if I am missing something. Any ideas?
This error probabily is because the image base is nanoserver in this case, and then the react-scripts don't works well. Also the docker images from stefanscherer/node-windows arn't updates (the latest versions of NodeJs in these images are 12.x).
Because this, I made one new docker image with some LTS versions as 14.19.0, 16.17.0 for example.
The docker image is henriqueholtz/node-win, where the tags are the NodeJs versions.
Note: For now, the NodeJs don't have official image to windows container.
In the README in docker hub, you can see one example and the links to some articles with more examples.
See some articles with examples:
How to run ReactJs app on Windows container
How to execute windows container with NodeJs
Below one example to run your create-react-app, for example (obviously, you must change the volume to your folder - use powershell):
docker run -t -p 3000:3000 --name=my-own-cra-windows-container -v C:\Projects\my-own-cra\:C:\app\ henriqueholtz/node-win:16.17.0 cmd /c "npm -v & node -v & npm start"