I have a NODE.js application which will run only in the Windows environment.
I am running docker desktop on windows 10 Enterprise edition. Docker server version: 20.10.14. So I have switched to the windows container in the docker desktop to create a windows container.
When I am running the container using the docker run command, the container does not start and throws the error.
C:\Users\app>docker run -d helloapp:latest -p 8085:8085
7286c4a0d38c87ec09c009a59cdda527f939f7e7b2814c2324f52cd454744658.
docker: Error response from daemon: container 7286c4a0d38c87ec09c009a59 encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail: Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(174)\vmcomputeagent.exe!00007FF67F5BC00A: (caller: 00007FF67F58ECEA) Exception(2) tid(36c) 80070002 The system cannot find the file specified.
CallContext:[\Bridge_ProcessMessage\ComputeSystemManager_ExecuteProcess\VmHostedContainer_ExecuteProcess]
Provider: 00000000-0000-0000-0000-000000000000].
Here is my docker file:
FROM customnode/node:12.14.1
RUN mkdir C:\\applications\\docker-firstapp
COPY myfirstapp C:\\applications\\docker-firstapp
WORKDIR C:\\applications\\docker-firstapp
RUN npm install
ENV PORT=8085
ENV SQL_USER=username
ENV SQL_PASSWORD=passwd
ENV SQL_SERVER=serverip
ENV SQL_SERVER_DB=dbname
ENV SQL_SERVER_PORT=1433
RUN npm run build
CMD ["npm", "run prod", "--port 8085"]
My folder structure:
*+--- myfirstapp
--- .dockerignore
--- Dockerfile*
For building the image:
docker build -t helloapp .
For running the container:
docker run -d helloapp:latest -p 8085:8085
Docker build logs:
C:\Users\app>docker build -t helloapp .
Sending build context to Docker daemon 12.85MB
Step 1/12 : FROM customnode/node:12.14.1
12.14.1: Pulling from customnode/node
e46122273a4e: Pull complete
c37a24ce81a9: Pull complete
Digest: sha256:ccd9d53710c8b8f8fd4bb779afe79bhd8d45dugf44c4ddf7b7f655ea5cbfe540550cd892c
Status: Downloaded newer image for customnode/node:12.14.1
---> 2cb9637cf0ec
Step 2/12 : RUN mkdir C:\\applications\\docker-firstapp
---> Running in b5c9bc1fabe0
Removing intermediate container b5c9bc1fabe0
---> bc300a981554
Step 3/12 : COPY myfirstapp C:\\applications\\docker-firstapp
---> b039e12ed5de
Step 4/12 : WORKDIR C:\\applications\\docker-firstapp
---> Running in a522ca627602
Removing intermediate container a522ca627602
---> fe67791910c9
Step 5/12 : RUN npm install
---> Running in 796e435a9ecf
added 628 packages from 996 contributors in 63.929s
Removing intermediate container 796e435a9ecf
---> 2301e525f348
Step 6/12 : ENV PORT=8085
---> Running in 43b2cfe4f50b
Removing intermediate container 43b2cfe4f50b
---> 56babd0dfc87
Step 7/12 : ENV SQL_USER=username
---> Running in 7a7b5c3164c3
Removing intermediate container 7a7b5c3164c3
---> cff0b54056f6
Step 8/12 : SQL_PASSWORD=passwd
---> Running in 162832e5b80d
Removing intermediate container 162832e5b80d
---> c4cc16d73439
Step 9/12 : ENV SQL_SERVER=serverip
---> Running in 22f010aaa9c6
Removing intermediate container 22f010aaa9c6
---> fba9cb278a2a
Step 10/12 : ENV SQL_SERVER_DB=dbname
---> Running in 37f14891e5ed
Removing intermediate container 37f14891e5ed
---> 22477a823bdd
Step 11/12 : ENV SQL_SERVER_PORT=1433
---> Running in a0b9ec381efd
Removing intermediate container a0b9ec381efd
---> 30bc3fb6d543
Step 12/12 : RUN npm run build
---> Running in f6b3b0c7ec9b
> nodewithtypescript#1.0.0 build C:\applications\docker-firstapp
> tsc
Removing intermediate container f6b3b0c7ec9b
---> da1352245135
Step 12/12 : CMD ["npm", "run prod", "--port 8085"]
---> Running in 744719faa7c3
Removing intermediate container 744719faa7c3
---> 1912b73a80d5
Successfully built 1912b73a80d5
Successfully tagged helloapp:latest
I have what I believe is a pretty simple setup.
I build a binary file outside of docker and then try to add it using this Dockerfile
FROM alpine
COPY apps/dist/apps /bin/
RUN chmod +x /bin/apps
RUN ls -al /bin | grep apps
CMD /bin/apps
And I think this should work.
The binary on its own seems to work on my host machine and I don't understand why it wouldn't on the docker image.
Anyways, the output I get is this:
docker build -t apps -f app.Dockerfile . && docker run apps
Sending build context to Docker daemon 287.5MB
Step 1/5 : alpine
---> d05cf6536f67
Step 2/5 : COPY apps/dist/apps /bin/
---> Using cache
---> c54d6d57154e
Step 3/5 : RUN chmod +x /bin/apps
---> Using cache
---> aa7e6adb0981
Step 4/5 : RUN ls -al /bin | grep apps
---> Running in 868c5e235d68
-rwxr-xr-x 1 root root 68395166 Dec 20 13:35 apps
Removing intermediate container 868c5e235d68
---> f052c06269b0
Step 5/5 : CMD /bin/apps
---> Running in 056fd02733e1
Removing intermediate container 056fd02733e1
---> 331600154cbe
Successfully built 331600154cbe
Successfully tagged apps:latest
/bin/sh: /bin/apps: not found
does this make sense, and am I just missing something obvious?
Your binary likely has dynamic links to libraries that don't exist inside the image filesystem. You can check those dynamic links with the ldd apps/dist/apps command.
I'm trying to make a container of my builded angular app.
I have already build my app. so inside actual folder I have
dist/ src/ and root files
Here's my docker folder
FROM node:alpine AS builder
WORKDIR /app
COPY . .
FROM nginx:alpine
COPY --from=builder /app/dist/* /usr/share/nginx/html/
built is ok
docker build -t ngapp:1.0.9 .
Step 1/5 : FROM node:alpine AS builder
---> 2d8f48ba52b1
Step 2/5 : WORKDIR /app
---> Using cache
---> d8d0d9d93f72
Step 3/5 : COPY . .
---> Using cache
---> 87c12f8c2ccf
Step 4/5 : FROM nginx:alpine
---> 36189e6707f4
Step 5/5 : COPY --from=builder /app/dist/* /usr/share/nginx/html/
---> Using cache
---> e39f00401242
Successfully built e39f00401242
I run my app
sudo docker run -p 8956:8080 ngapp:1.0.9
But when I go on the web page adresse the site is not running I get message : this site is not accessible
The nginx container doesn't listen on port 8080 (by default), so simply map to the valid port:
ports:
- 8956:80
I'm working behind a corporate proxy. I'm on Windows 10 machine but I'm also running VMware. Inside VMware I'm running a Fedora 28 image. Because I'm behind a corporate proxy I have to run an NTLM proxy server on Windows 10 so that Fedora can connect to the internet.
I have everything set up and I can access the internet and pull docker images perfectly. I'm following this tutorial here on docker-compose.
This is my directory structure:
docker-compose-tut
├── commander
│ └── Dockerfile
└── docker-compose.yml
Dockerfile
FROM node:latest
ENV http_proxy=http://prx:3128
ENV https_proxy=http://prx:3128
ENV ftp_proxy=http://prx:3128
ENV no_proxy=localhost,127.0.0.1
RUN curl -L https://github.com/joeferner/redis-commander/tarball/v0.4.5 | tar zx
RUN npm install -g redis-commander
ENTRYPOINT ["redis-commander"]
CMD ["--redis-host", "redis"]
EXPOSE 8081
docker-compose.yml
backend:
image: redis:latest
restart: always
frontend:
build: commander
links:
- backend:redis
environment:
- ENV_VAR1 = some_value
ports:
- 8081:8081
environment:
- VAR1=value
restart: always
When I run the command docker-compose up -d I get the following output
[root#localhost docker-compose-tut]$ docker-compose up -d
Building frontend
Step 1/10 : FROM node:latest
---> b064644cf368
Step 2/10 : ENV http_proxy http://prx:3128
---> Using cache
---> f70ae2e24003
Step 3/10 : ENV https_proxy http://prx:3128
---> Using cache
---> 12a4e65a3874
Step 4/10 : ENV ftp_proxy http://prx:3128
---> Using cache
---> 77abdce2f8d7
Step 5/10 : ENV no_proxy localhost,127.0.0.1
---> Using cache
---> 467c4f25e4f7
Step 6/10 : RUN curl -L https://github.com/joeferner/redis-commander/tarball/v0.4.5 | tar zx
---> Using cache
---> e3f8b2d8ad64
Step 7/10 : RUN npm install -g redis-commander
---> Running in 3189b0fa1086
npm WARN deprecated ejs#0.8.8: Critical security bugs fixed in 2.5.5
When I enter the command docker-compose ps this is literally the output
Name Command State Ports
------------------------------
When I enter the command docker-compose --services the output is the following:
backend
frontend
If I open the browser and enter http://localhost:8081 the browser says that it can't establish a connection to http://localhost:8081.
What am I doing wrong?
Here's my compose file:
version: '2'
services:
web:
build: ./web
ports:
- "3000:3000"
links:
- api
api:
build: ./api
links:
- db
db:
image: postgres
Here is my Dockerfile for the web service:
FROM node:8.9.3
WORKDIR /app
COPY ./package.json /app
COPY ./server /app/server
COPY ./client /app/client
EXPOSE 3000
ENV PORT 3000
RUN ["npm", "install"]
ENTRYPOINT ["npm", "start"]
And for the api project:
FROM python:3.6
WORKDIR /api
COPY ./requirements.txt /api/requirements.txt
COPY ./src /api/src
EXPOSE 80
ENV PORT 80
RUN ["pip", "install", "-r", "requirements.txt"]
RUN ["python", "src/main.py"]
When I run docker-compose up, only the api service starts. However, if I comment out the api service altogether and run docker-compose up again, both the web and db services start. Is there something wrong with how I've set up the api project? What am I doing wrong?
Just for completeness, here is the starting file for the web project (uses Express)
http.createServer(app).listen(app.get("port"), function() {
console.log("Express server listening on port " + app.get("port"));
});
and the api proj (uses Flask):
from flask import Flask
app = Flask(__name__)
#app.route("/")
def hello():
return "Hello World!"
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=80)
UPDATE
I commented out the main line of my flask server and all 3 services are able to start. The downside is... now i dont have an api server. What is it about Flask that makes the other services unusable?
UPDATE 2
Some have requested to see the logs.
Here are the logs if i start without flask:
Building web
Step 1/10 : FROM node:8.9.3
---> 2eeae8debf3d
Step 2/10 : WORKDIR /app
---> Using cache
---> 02199a27dafb
Step 3/10 : COPY ./package.json /app
---> Using cache
---> fafac64ad492
Step 4/10 : COPY ./app.js /app
---> Using cache
---> 0b1e3067451b
Step 5/10 : COPY ./controllers /app/server
---> Using cache
---> ff00fa864078
Step 6/10 : COPY ./client /app/client
---> Using cache
---> 587214c84267
Step 7/10 : EXPOSE 3000
---> Using cache
---> ddd5b795fcf5
Step 8/10 : ENV PORT 3000
---> Using cache
---> ca4c37f63468
Step 9/10 : RUN npm install
---> Using cache
---> 74b289885447
Step 10/10 : ENTRYPOINT npm start
---> Using cache
---> 9c5ec6770c47
Successfully built 9c5ec6770c47
Successfully tagged testcomposemachine_web:latest
Recreating testcomposemachine_web_1
Starting testcomposemachine_db_1
Attaching to testcomposemachine_db_1, testcomposemachine_web_1
db_1 | 2017-12-28 23:11:55.861 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2017-12-28 23:11:55.861 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2017-12-28 23:11:55.874 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2017-12-28 23:11:55.907 UTC [24] LOG: database system was shut down at 2017-12-28 22:59:27 UTC
db_1 | 2017-12-28 23:11:55.919 UTC [1] LOG: database system is ready to accept connections
web_1 |
web_1 | > docker-web#1.0.0 start /app
web_1 | > node app.js
web_1 |
web_1 | Express Web server listening on port 3000
Here are the logs if i include flask:
Building api
Step 1/8 : FROM python:3.6
---> c1e459c00dc3
Step 2/8 : WORKDIR /api
---> Using cache
---> 8c9da963377c
Step 3/8 : COPY ./requirements.txt /api/requirements.txt
---> Using cache
---> 654c815801f6
Step 4/8 : COPY ./src /api/src
---> 5627279f7323
Removing intermediate container 453bf031c2f7
Step 5/8 : EXPOSE 80
---> Running in efb18f950f7d
---> 1389c63a0bcb
Removing intermediate container efb18f950f7d
Step 6/8 : ENV PORT 80
---> Running in 2ad88bed6343
---> fa85201cc165
Removing intermediate container 2ad88bed6343
Step 7/8 : RUN pip install -r requirements.txt
---> Running in e19107f5a449
Collecting flask==0.12.2 (from -r requirements.txt (line 1))
Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB)
Collecting itsdangerous>=0.21 (from flask==0.12.2->-r requirements.txt (line 1))
Downloading itsdangerous-0.24.tar.gz (46kB)
Collecting Werkzeug>=0.7 (from flask==0.12.2->-r requirements.txt (line 1))
Downloading Werkzeug-0.13-py2.py3-none-any.whl (311kB)
Collecting click>=2.0 (from flask==0.12.2->-r requirements.txt (line 1))
Downloading click-6.7-py2.py3-none-any.whl (71kB)
Collecting Jinja2>=2.4 (from flask==0.12.2->-r requirements.txt (line 1))
Downloading Jinja2-2.10-py2.py3-none-any.whl (126kB)
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->flask==0.12.2->-r requirements.txt (line 1))
Downloading MarkupSafe-1.0.tar.gz
Building wheels for collected packages: itsdangerous, MarkupSafe
Running setup.py bdist_wheel for itsdangerous: started
Running setup.py bdist_wheel for itsdangerous: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/fc/a8/66/24d655233c757e178d45dea2de22a04c6d92766abfb741129a
Running setup.py bdist_wheel for MarkupSafe: started
Running setup.py bdist_wheel for MarkupSafe: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/88/a7/30/e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57
Successfully built itsdangerous MarkupSafe
Installing collected packages: itsdangerous, Werkzeug, click, MarkupSafe, Jinja2, flask
Successfully installed Jinja2-2.10 MarkupSafe-1.0 Werkzeug-0.13 click-6.7 flask-0.12.2 itsdangerous-0.24
---> a7be838d3a6e
Removing intermediate container e19107f5a449
Step 8/8 : RUN python src/main.py
---> Running in e86c8adf46f0
* Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
Notice how when flask is included the other containers dont even build?
You have a RUN command that can not finish in your app dockerfile. This is preventing your dockerfile from ever finishing building. It's why it says step 8/8 and never says "successfully built" like your web container. I'd move that last run command into an entrypoint or CMD, like you have it in your web docker file, so that way the docker build command can actually finish.
IE CMD ["python", "src/main.py"] or ENTRYPOINT ["python", "src/main.py"]
That is most likely what is preventing your docker images from being built. Is because of that one last line in APP where you are starting a webserver in the foreground which never closes. Best bet is to place the command into entrypoint so it does not actually run during the build process, but will run when the image is started.
this is the line I'm talking about:
Step 8/8 : RUN python src/main.py
---> Running in e86c8adf46f0
* Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
VS this one out of the web build.
Step 10/10 : ENTRYPOINT npm start
---> Using cache
---> 9c5ec6770c47
Successfully built 9c5ec6770c47
Successfully tagged testcomposemachine_web:latest
Recreating testcomposemachine_web_1
Starting testcomposemachine_db_1
Attaching to testcomposemachine_db_1, testcomposemachine_web_1
the build will never finish if the command never completes. So yes, in a way the Flask API is preventing your docker-compose command from building all the other files.