# Problem with connection between nodejs container to mongo container

**URL:** <https://forums.docker.com/t/problem-with-connection-between-nodejs-container-to-mongo-container/119985>\
**Category:** General\
**Created:** [January 18, 2022, 7:31am UTC](https://forums.docker.com/t/problem-with-connection-between-nodejs-container-to-mongo-container/119985 "2022-01-18T07:31:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rachelc8](https://avatars.discourse-cdn.com/v4/letter/r/e47c2d/32.png) [@rachelc8](https://forums.docker.com/u/rachelc8)\
**Post date:** [January 18, 2022, 7:31am UTC](https://forums.docker.com/t/problem-with-connection-between-nodejs-container-to-mongo-container/119985/1 "2022-01-18T07:31:40Z")

</div>

Hi,  
I have some question if it’s possible:  
I built a project in Nodejs- in Docker,  
And I wont connect it to **mongodb** container,  
the mongo db container run with the data- without problems:

```auto
cdrachelllinux@DESKTOP-R9ESLDU:/mnt/c`Preformatted text`/Users/RachelCohen$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9a3bcc06c95d mongo "docker-entrypoint.s…" 12 hours ago Up 12 hours 27017/tcp mongodb

```

The node js project can connect to regular mongodb (not mongo Docker container) ,  
and when I connect it to mongo container- with connectionstring,

```auto
 mongoose.connect(`process.env.MONGODB_CONNSTRING`,{

```

and build the node js project image, and run the node project container-  
**it’s exited immediately**

when I checked what is the problem I got:

```auto
cdrachelllinux@DESKTOP-R9ESLDU:/mnt/c/Users/RachelCohen/DockerProject/ApiGenerator$ docker run --name kjh -p 3070:3070 r
achelc8/cdcdcdcdcdcdm .
**/usr/local/bin/docker-entrypoint.sh: exec: line 11: .: Permission denied**

```

the node Dockerfile is:

```auto
FROM node:lts-alpine
ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install --production --silent && mv node_modules ../
COPY . .
EXPOSE 3070
RUN chown -R node /usr/src/app
USER node
CMD ["npm", "start"]

```

when I tried this:

```auto
chmod +x entrypoint.sh

```

I got:

```auto
chmod: cannot access 'entrypoint.sh': No such file or directory

```

and when I added entrypoint to the Dockerfile:

```auto
FROM node:lts-alpine
ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install --production --silent && mv node_modules ../
COPY . .
EXPOSE 3070
RUN chown -R node /usr/src/app
USER node
**ENTRYPOINT ["/docker-entrypoint.sh"]**
CMD ["npm", "start"]

```

(and build and ran again) I got:

```auto
cdrachelllinux@DESKTOP-R9ESLDU:/mnt/c/Users/RachelCohen/DockerProject/ApiGenerator$ docker run --name kcdjh -p 3070:3070
 rachelc8/cdcdcdcdcdcdmp .
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/docker-entrypoint.sh": stat /docker-entrypoint.sh: no such file or directory: unknown.
ERRO[0002] error waiting for container: context canceled

```

If you know what the problem is-  
It will help me a lot!  
thank you!

---

<div class="post-metadata">

**Author:** ![terpz](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/terpz/32/36125_2.png) [@terpz](https://forums.docker.com/u/terpz)\
**Post date:** [January 18, 2022, 8:06am UTC](https://forums.docker.com/t/problem-with-connection-between-nodejs-container-to-mongo-container/119985/2 "2022-01-18T08:06:50Z")

</div>

Hi 🙂

You say in your dockerfile, that the ENTRYPOINT script is at /docker-entrypoint.sh, but according to the github of node, its not where it is:  
([docker-node/Dockerfile at main · nodejs/docker-node · GitHub](https://github.com/nodejs/docker-node/blob/main/17/buster/Dockerfile))

```auto
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]

```

So i belive that if you remove the / in your ENTRYPOINT, i belive it will work.

---

<div class="post-metadata">

**Author:** ![rachelc8](https://avatars.discourse-cdn.com/v4/letter/r/e47c2d/32.png) [@rachelc8](https://forums.docker.com/u/rachelc8)\
**Post date:** [January 18, 2022, 8:12am UTC](https://forums.docker.com/t/problem-with-connection-between-nodejs-container-to-mongo-container/119985/3 "2022-01-18T08:12:43Z")

</div>

Hi!  
first-thank you very much!  
second-  
I would love to know what you mean, because I tried without the entrypoint - I showed up - before I added the entrypoint  
Thanks!

---

<div class="post-metadata">

**Author:** ![rachelc8](https://avatars.discourse-cdn.com/v4/letter/r/e47c2d/32.png) [@rachelc8](https://forums.docker.com/u/rachelc8)\
**Post date:** [January 18, 2022, 8:38am UTC](https://forums.docker.com/t/problem-with-connection-between-nodejs-container-to-mongo-container/119985/4 "2022-01-18T08:38:49Z")

</div>

Hi!

I didn’t find the entrypoint,  
should I create it myself ? how?

thank you!
